Hello people,
Can you tell me how can I get the rows that are with color red in my RadGrid?? which is the property? I need to count them to update a text on a button, but the problem is that those rows are not selected, so I can't count them by item.selected property..
The button(Unprocessed) is not counting the Processed and updating the text because there are none "Selected" so the counting appears like "Processed (0) Total(300) " when you can see rows at red...can i get those rows to count?
Here is my code:
Can you tell me how can I get the rows that are with color red in my RadGrid?? which is the property? I need to count them to update a text on a button, but the problem is that those rows are not selected, so I can't count them by item.selected property..
The button(Unprocessed) is not counting the Processed and updating the text because there are none "Selected" so the counting appears like "Processed (0) Total(300) " when you can see rows at red...can i get those rows to count?
Here is my code:
18 Answers, 1 is accepted
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2011, 09:37 AM
Hello,
Let me know if any concern.
Thanks,
Jayesh Goyani
protected
void
RadButton2_Click(
object
sender, EventArgs e)
{
int
TotalCount = 0;
RadGrid1.MasterTableView.AllowPaging =
false
;
//RadGrid1.Skin = "Black";
RadGrid1.Rebind();
int
Selectedcount = 0;
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(AppliedSelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
TotalCount ++;
}
if
(item.Selected)
{
_AppliedSelectedID = _AppliedSelectedID.Replace(Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
,
""
);
}
}
RadButton2.Text =
"Selected :("
+ Selectedcount.ToString() +
")"
+
" Total :("
+ TotalCount .ToString() +
")"
;
RadGrid1.MasterTableView.AllowPaging =
true
;
RadGrid1.Rebind();
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 09:53 AM
Hello Jayesh..I have a button3 only to show the text, if you look at my code above on the Button1 I have this line
What I want to do is keep tracking those numbers on the RadButton2 updating the text of my button3, like Processed : "total red rows" and Unprocessed "total gridrows - total red rows"
I appologyse but i'm not understandig the button text that you are tracking on your method...After tried it when I have only one row at red the text appears like that: Selected:0 Total 2....
RadButton3.Text = "Processed :(" + Selectedcount.ToString() + ")" + " Unprocessed :(" + (RadGrid1.Items.Count - Selectedcount).ToString() + ")";
What I want to do is keep tracking those numbers on the RadButton2 updating the text of my button3, like Processed : "total red rows" and Unprocessed "total gridrows - total red rows"
I appologyse but i'm not understandig the button text that you are tracking on your method...After tried it when I have only one row at red the text appears like that: Selected:0 Total 2....
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 10:12 AM
Hello Jayesh I've solved the problem of the countings thanks to your help.
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 11:59 AM
Hello Jayesh!
I made some changes on your code and adapted to my case and the counting problem are solved.
However I found another issue on the solution you provided me yesterday to mark rows with color.
The issue is, if you try your code, you can see that:
if you select 3 rows, click on processed button(RadButton1), those rows will be marked red, then if you select one or two rows and click the Unprocessed button(RadButton2), those rows return correctly to the default color, but stay Selected.
This is a problem, because if you then select some rows and click the Processed button, the previous rows marked, return to default and only the rows you have now click as processed
I made some changes on your code and adapted to my case and the counting problem are solved.
However I found another issue on the solution you provided me yesterday to mark rows with color.
The issue is, if you try your code, you can see that:
if you select 3 rows, click on processed button(RadButton1), those rows will be marked red, then if you select one or two rows and click the Unprocessed button(RadButton2), those rows return correctly to the default color, but stay Selected.
This is a problem, because if you then select some rows and click the Processed button, the previous rows marked, return to default and only the rows you have now click as processed
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 12:31 PM
Can you show me I can I avoid the selected row unprocessed became not selected?
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2011, 12:44 PM
Hello,
let me know if any concern.
Thanks,
Jayesh Goyani
protected
void
UnProceedButton_Click(
object
sender, EventArgs e)
{
................
..................
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(item.Selected)
{
_AppliedSelectedID = _AppliedSelectedID.Replace(Convert.ToInt64(item.GetDataKeyValue(
"SequencialNumber"
)).ToString() +
","
,
""
);
_SelectedID = _SelectedID.Replace(Convert.ToInt64(item.GetDataKeyValue(
"SequencialNumber"
)).ToString() +
","
,
""
);
}
}
..................
.................
}
let me know if any concern.
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 12:55 PM
Hello Jayesh thanks a lot for your support!!
I d'ont get there alone because i'm having some difficult to understand how both _SelectedID() and _AppiedSelectedID() methods works on your solution...I've tried to do something like code bellow, but nothings change...
I d'ont get there alone because i'm having some difficult to understand how both _SelectedID() and _AppiedSelectedID() methods works on your solution...I've tried to do something like code bellow, but nothings change...
foreach (GridDataItem item in RadGrid1.Items)
{
if (_AppliedSelectedID.Contains("," + Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ","))
{
TotalCount++;
}
if (item.Selected)
{
_AppliedSelectedID = _AppliedSelectedID.Replace(Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ",", "");
//Solution // _SelectedID = _SelectedID.Replace(Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ",", "");
Selectedcount2++;
//-------> item.Selected = false;
}
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 01:02 PM
Hello again Jayesh...still having a problem...After I select one row and click the Unprocessed, then that row became correctly Unselected, however if then i'm continuing selecting rows to mark as processed(even with the CTRL key) previous marked rows return to default and only the last selection made becomes marked(RED).
It's possible to solve this issue?
Thanks one more time
It's possible to solve this issue?
Thanks one more time
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 01:29 PM
Hello Jaeysh in other words, every time I make unprocessed rows, when i continue to mark processed I have to select all the rows again...Are you understanding?
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2011, 05:49 PM
Hello,
Put another button to reset grid.
Let me know if any concern.
Thanks,
Jayesh Goyani
Put another button to reset grid.
<
telerik:RadButton
ID
=
"RadButton4"
runat
=
"server"
Text
=
"Reset"
Skin
=
"Black"
Width
=
"100px"
Height
=
"50px"
OnClick
=
"RadButton4_Click"
>
</
telerik:RadButton
>
protected
void
RadButton4_Click(
object
sender, EventArgs e)
{
_SelectedID =
",0,"
;
_AppliedSelectedID =
string
.Empty;
RadGrid1.Rebind();
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 05:55 PM
Hello Jayesh
Ok, but wicht is the purpose?
I d'ont need to reset the grid...I only want to after a click to unprocessed a row, after that i want to continue selecting rows and clicking on Processed Button, and I need the grid d'ont clear previous rows selected but keep them and the new ones....
Ok, but wicht is the purpose?
I d'ont need to reset the grid...I only want to after a click to unprocessed a row, after that i want to continue selecting rows and clicking on Processed Button, and I need the grid d'ont clear previous rows selected but keep them and the new ones....
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2011, 06:08 PM
Hello,
first of all you select first,second and third row then click on proceed. so it convert to Red row.
then User Select First row and then click on UnProceed . so it remove Red Color from First row.
Now still second and third row with Red color.
now what you want ?
Let me know so i help you.
Thanks,
Jayesh Goyani
first of all you select first,second and third row then click on proceed. so it convert to Red row.
then User Select First row and then click on UnProceed . so it remove Red Color from First row.
Now still second and third row with Red color.
now what you want ?
Let me know so i help you.
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 06:13 PM
Now after that, User click with CTRL Key Select another row and click processed...AND here is the problem....only that last row will be marked(red) the previus two are at the default....And I need them to stay....keep the history , understand?
0

Ricardo
Top achievements
Rank 1
answered on 12 Aug 2011, 06:15 PM
At this point the grid should have second and third row plus the last row at RED....3 Rows marked....and what the grid does is keep only this last row marked red....the second and the third becomes default color....are you understanding?
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Aug 2011, 07:16 PM
Hello,
please check below code.
Please update/modify below code with your code.
let me know if any concern.
Thanks,
Jayesh Goyani
please check below code.
Please update/modify below code with your code.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TelerikTest.Web.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
style
type
=
"text/css"
>
.RadGrid_Black .rgFilterBox
{
background-color: #454545 !important;
}
.TextCss
{
background: red !important;
}
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AllowMultiRowSelection
=
"True"
OnPreRender
=
"RadGrid1_PreRender"
onitemcommand
=
"RadGrid1_ItemCommand"
onitemdatabound
=
"RadGrid1_ItemDataBound"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
UniqueName
=
"ID"
SortExpression
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
SortExpression
=
"Name"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
br
/>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Processed"
Skin
=
"Black"
Width
=
"100px"
Height
=
"50px"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
Text
=
"UNProcessed"
Skin
=
"Black"
Width
=
"100px"
Height
=
"50px"
onclick
=
"RadButton2_Click"
>
</
telerik:RadButton
>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
using
System.Drawing;
namespace
TelerikTest.Web
{
public
partial
class
WebForm1 : System.Web.UI.Page
{
public
bool
_IsStyleApply
{
set
{
ViewState[
"IsStyleApply"
] = value;
}
get
{
if
(ViewState[
"IsStyleApply"
] !=
null
)
{
return
Convert.ToBoolean(ViewState[
"IsStyleApply"
]);
}
else
{
return
false
;
}
}
}
public
string
_SelectedID
{
set
{
ViewState[
"SelectedID"
] = value;
}
get
{
if
(ViewState[
"SelectedID"
] !=
null
)
{
return
Convert.ToString(ViewState[
"SelectedID"
]);
}
else
{
return
",0,"
;
}
}
}
public
string
_AppliedSelectedID
{
set
{
ViewState[
"AppliedSelectedID"
] = value;
}
get
{
if
(ViewState[
"AppliedSelectedID"
] !=
null
)
{
return
Convert.ToString(ViewState[
"AppliedSelectedID"
]);
}
else
{
//change
return
",0,"
;
}
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
_IsStyleApply =
false
;
_SelectedID =
",0,"
;
_AppliedSelectedID =
",0,"
;
}
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.AllowPaging =
false
;
RadGrid1.Rebind();
int
Selectedcount = 0;
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(item.Selected)
{
Selectedcount++;
}
item.Selected =
false
;
}
RadButton1.Text =
"Selected :("
+ Selectedcount.ToString() +
")"
+
" Total :("
+ RadGrid1.Items.Count.ToString() +
")"
;
RadGrid1.MasterTableView.AllowPaging =
true
;
_IsStyleApply =
true
;
_AppliedSelectedID += _SelectedID;
_SelectedID =
",0,"
;
RadGrid1.Rebind();
}
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
if
(_IsStyleApply)
{
//RadGrid1.SelectedItemStyle.CssClass = "TextCss";
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(_AppliedSelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
item.CssClass =
"TextCss"
;
}
}
}
}
protected
void
RadGrid1_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
},
new
{ ID = 2, Name =
"Name2"
},
new
{ ID = 3, Name =
"Name3"
},
new
{ ID = 4, Name =
"Name4"
},
new
{ ID = 5, Name =
"Name5"
},
new
{ ID = 6, Name =
"Name6"
},
new
{ ID = 7, Name =
"Name7"
},
new
{ ID = 8, Name =
"Name8"
},
new
{ ID = 9, Name =
"Name9"
},
new
{ ID = 10, Name =
"Name10"
},
new
{ ID = 11, Name =
"Name11"
},
new
{ ID = 12, Name =
"Name12"
},
new
{ ID = 13, Name =
"Name13"
},
new
{ ID = 14, Name =
"Name14"
},
new
{ ID = 15, Name =
"Name15"
}
};
RadGrid1.DataSource = data;
}
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"RowClick"
)
{
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(item.Selected)
{
if
(!_SelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
_SelectedID = _SelectedID + Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
;
}
}
else
{
_SelectedID = _SelectedID.Replace(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
,
","
);
}
}
}
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = e.Item
as
GridDataItem;
if
(_SelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
item.Selected =
true
;
}
}
}
protected
void
RadButton2_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.AllowPaging =
false
;
RadGrid1.Rebind();
int
Selectedcount = 0;
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(item.Selected)
{
_AppliedSelectedID = _AppliedSelectedID.Replace(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
,
","
);
}
}
RadButton2.Text =
"Selected :("
+ Selectedcount.ToString() +
")"
+
" Total :("
+ RadGrid1.Items.Count.ToString() +
")"
;
RadGrid1.MasterTableView.AllowPaging =
true
;
_SelectedID =
",0,"
;
_AppliedSelectedID = _AppliedSelectedID.Replace(
",,"
,
","
);
RadGrid1.Rebind();
}
}
}
let me know if any concern.
Thanks,
Jayesh Goyani
0

Ricardo
Top achievements
Rank 1
answered on 16 Aug 2011, 10:36 AM
Hello Jayesh thanks for the help..
With your changes my counting now are wrong.. Can you give me a litle hand? The problem is that the selectedCount are beeing set to 0 everytime I make a second Select and click processed action..the variable selectedCount have allways the value of the second selection...
that's my code:
With your changes my counting now are wrong.. Can you give me a litle hand? The problem is that the selectedCount are beeing set to 0 everytime I make a second Select and click processed action..the variable selectedCount have allways the value of the second selection...
that's my code:
int Selectedcount = 0;
/// <
summary
>
/// No evento Click button seleciona facturas
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void RadButton1_Click(object sender, EventArgs e)
{
RadGrid1.MasterTableView.AllowPaging = false;
//RadGrid1.Skin = "Black";
RadGrid1.Rebind();
foreach (GridDataItem item in RadGrid1.Items)
{
if (item.Selected)
{
Selectedcount++;
}
//NEW
item.Selected = false;
}
RadButton3.Text = "Processed :(" + Selectedcount.ToString() + ")" + " Unprocessed :(" + (RadGrid1.Items.Count - Selectedcount).ToString() + ")";
RadGrid1.MasterTableView.AllowPaging = true;
//RadGrid1.Items.Count --> Total de linhas existentes
// below line added recently
_IsStyleApply = true;
//NEW +=
_AppliedSelectedID += _SelectedID;
//NEW
_SelectedID = ",0,";
RadGrid1.Rebind();
}
/// <
summary
>
/// Evento que elimina facturas selecionadas
/// </
summary
>
/// <
param
name
=
"sender"
></
param
>
/// <
param
name
=
"e"
></
param
>
protected void RadButton2_Click(object sender, EventArgs e)
{
int TotalCount = 0;
RadGrid1.MasterTableView.AllowPaging = false;
RadGrid1.Rebind();
int Selectedcount2 = 0;
foreach (GridDataItem item in RadGrid1.Items)
{
if (_AppliedSelectedID.Contains("," + Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ","))
{
TotalCount++;
}
if (item.Selected)
{
_AppliedSelectedID = _AppliedSelectedID.Replace("," + Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ",", ",");
Selectedcount2++;
}
//if (item.Selected)
//{
// _AppliedSelectedID = _AppliedSelectedID.Replace(Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ",", "");
// _SelectedID = _SelectedID.Replace(Convert.ToInt64(item.GetDataKeyValue("SequencialNumber")).ToString() + ",", "");
// Selectedcount2++;
//}
}
int totalRemaining = TotalCount - Selectedcount2;
RadButton3.Text = "Processed :(" + totalRemaining.ToString() + ")" + " Unprocessed :(" + (RadGrid1.Items.Count - totalRemaining).ToString() + ")";
RadGrid1.MasterTableView.AllowPaging = true;
_SelectedID = ",0,";
_AppliedSelectedID = _AppliedSelectedID.Replace(",,", ",");
RadGrid1.Rebind();
}
0

Ricardo
Top achievements
Rank 1
answered on 16 Aug 2011, 10:39 AM
Hello, i verify that in your solution you have the same problem...The selected processed rows count are wron,,,and the unprocessed count to..
With your code it's possible to keep those values?
With your code it's possible to keep those values?
0

Jayesh Goyani
Top achievements
Rank 2
answered on 16 Aug 2011, 07:41 PM
Hello,
Let me know if any concern.
Thanks,
Jayesh Goyani
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TelerikTest.Web.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
style
type
=
"text/css"
>
.RadGrid_Black .rgFilterBox
{
background-color: #454545 !important;
}
.TextCss
{
background: red !important;
}
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
AllowFilteringByColumn
=
"True"
ShowFooter
=
"True"
Skin
=
"Black"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AllowMultiRowSelection
=
"True"
OnPreRender
=
"RadGrid1_PreRender"
onitemcommand
=
"RadGrid1_ItemCommand"
onitemdatabound
=
"RadGrid1_ItemDataBound"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
UniqueName
=
"ID"
SortExpression
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
SortExpression
=
"Name"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
br
/>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Processed"
Skin
=
"Black"
Width
=
"100px"
Height
=
"50px"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
Text
=
"UNProcessed"
Skin
=
"Black"
Width
=
"100px"
Height
=
"50px"
onclick
=
"RadButton2_Click"
>
</
telerik:RadButton
><
br
/><
asp:Label
ID
=
"Lablel1"
runat
=
"server"
></
asp:Label
>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
using
System.Drawing;
namespace
TelerikTest.Web
{
public
partial
class
WebForm1 : System.Web.UI.Page
{
public
bool
_IsStyleApply
{
set
{
ViewState[
"IsStyleApply"
] = value;
}
get
{
if
(ViewState[
"IsStyleApply"
] !=
null
)
{
return
Convert.ToBoolean(ViewState[
"IsStyleApply"
]);
}
else
{
return
false
;
}
}
}
public
string
_SelectedID
{
set
{
ViewState[
"SelectedID"
] = value;
}
get
{
if
(ViewState[
"SelectedID"
] !=
null
)
{
return
Convert.ToString(ViewState[
"SelectedID"
]);
}
else
{
return
",0,"
;
}
}
}
public
string
_AppliedSelectedID
{
set
{
ViewState[
"AppliedSelectedID"
] = value;
}
get
{
if
(ViewState[
"AppliedSelectedID"
] !=
null
)
{
return
Convert.ToString(ViewState[
"AppliedSelectedID"
]);
}
else
{
//change
return
",0,"
;
}
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
_IsStyleApply =
false
;
_SelectedID =
",0,"
;
_AppliedSelectedID =
",0,"
;
}
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.AllowPaging =
false
;
RadGrid1.Rebind();
int
Selectedcount = 0;
int
totalcount = 0;
int
proceedcount = 0;
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(item.Selected || _AppliedSelectedID.Contains(
","
+ item.GetDataKeyValue(
"ID"
).ToString()+
","
))
{
proceedcount++;
}
if
(item.Selected)
{
Selectedcount++;
}
item.Selected =
false
;
}
_IsStyleApply =
true
;
_AppliedSelectedID += _SelectedID;
_SelectedID =
",0,"
;
totalcount = RadGrid1.Items.Count;
Lablel1.Text =
"Selected :("
+ Selectedcount.ToString() +
") <br/>"
+
" Total :("
+ totalcount.ToString() +
") <br/> already Proceed and selected : ("
+ proceedcount.ToString() +
")"
;
RadGrid1.MasterTableView.AllowPaging =
true
;
RadGrid1.Rebind();
}
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
if
(_IsStyleApply)
{
//RadGrid1.SelectedItemStyle.CssClass = "TextCss";
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(_AppliedSelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
item.CssClass =
"TextCss"
;
}
}
}
}
protected
void
RadGrid1_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
},
new
{ ID = 2, Name =
"Name2"
},
new
{ ID = 3, Name =
"Name3"
},
new
{ ID = 4, Name =
"Name4"
},
new
{ ID = 5, Name =
"Name5"
},
new
{ ID = 6, Name =
"Name6"
},
new
{ ID = 7, Name =
"Name7"
},
new
{ ID = 8, Name =
"Name8"
},
new
{ ID = 9, Name =
"Name9"
},
new
{ ID = 10, Name =
"Name10"
},
new
{ ID = 11, Name =
"Name11"
},
new
{ ID = 12, Name =
"Name12"
},
new
{ ID = 13, Name =
"Name13"
},
new
{ ID = 14, Name =
"Name14"
},
new
{ ID = 15, Name =
"Name15"
}
};
RadGrid1.DataSource = data;
}
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"RowClick"
)
{
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(item.Selected)
{
if
(!_SelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
_SelectedID = _SelectedID + Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
;
}
}
else
{
_SelectedID = _SelectedID.Replace(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
,
","
);
}
}
}
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = e.Item
as
GridDataItem;
if
(_SelectedID.Contains(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
))
{
item.Selected =
true
;
}
}
}
protected
void
RadButton2_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.AllowPaging =
false
;
RadGrid1.Rebind();
int
totalCount = 0;
int
alreadyProceedcount = 0;
int
selectforunproceedcount = 0;
int
TotalProceedItem = 0;
foreach
(GridDataItem item
in
RadGrid1.Items)
{
if
(_AppliedSelectedID.Contains(
","
+ item.GetDataKeyValue(
"ID"
).ToString() +
","
))
{
alreadyProceedcount++;
}
if
(item.Selected)
{
selectforunproceedcount++;
_AppliedSelectedID = _AppliedSelectedID.Replace(
","
+ Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString() +
","
,
","
);
}
if
(_AppliedSelectedID.Contains(
","
+ item.GetDataKeyValue(
"ID"
).ToString() +
","
))
{
TotalProceedItem++;
}
item.Selected =
false
;
}
RadGrid1.MasterTableView.AllowPaging =
true
;
totalCount = RadGrid1.Items.Count;
_SelectedID =
",0,"
;
_AppliedSelectedID = _AppliedSelectedID.Replace(
",,"
,
","
);
RadGrid1.Rebind();
Lablel1.Text =
"Selectedforunproceed :("
+ selectforunproceedcount.ToString() +
")<br/>"
+
" TotalCount :("
+ totalCount.ToString() +
")<br/> 'Before Unproceed'alreadyProceedCount("
+
alreadyProceedcount.ToString()+
") <br/> TotalProceedItem: ("
+ TotalProceedItem.ToString() +
")"
;
}
}
}
Let me know if any concern.
Thanks,
Jayesh Goyani