shanker bangari
Top achievements
Rank 1
shanker bangari
asked on 11 Jun 2010, 08:00 AM
Hi,
I want GridClientSelectColumn value like "true or false" in custom button click event.Hi wrote this code it's not working how to find this
please how to find the value in button click event
| for (int i = 0; RadGrid2.Items.Count > i; i++) |
| { |
| CheckBox chk =(CheckBox)RadGrid2.Items[i].FindControl("ClientSelectColumn") as CheckBox; |
| if (chk != null) |
| { |
| if (chk.Checked == true) |
| { |
| TextBox1.Text = "shanker"; |
| } |
| } |
| } |
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2010, 08:39 AM
Hello Shankar,
You can try the following code snippet to get the ClientSelectColumn value in Button Click event.
ASPX:
C#:
Regards,
Shinu.
You can try the following code snippet to get the ClientSelectColumn value in Button Click event.
ASPX:
| <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn"> |
| </telerik:GridClientSelectColumn> |
C#:
| protected void Button1_Click(object sender, EventArgs e) |
| { |
| foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
| { |
| CheckBox chk = (CheckBox)item["ClientSelectColumn"].Controls[0]; |
| if (chk.Checked) |
| { |
| // your code |
| } |
| } |
| } |
Regards,
Shinu.
0
Rohan
Top achievements
Rank 1
answered on 22 Nov 2012, 02:56 PM
Hi shinu,
I am also facing the same issues , and i worked with your provided solution it doesn't work for me ,
it only works for last page of rad grid .. then i changed code this way ....
_grdDataListView.MasterTableView.AllowPaging = false;
_grdDataListView.Rebind();
int aas = _grdDataListView.Items.Count;
foreach (GridDataItem item in _grdDataListView.MasterTableView.Items)
{
CheckBox _chkBox = (CheckBox)item["ClientSelectColumn"].Controls[0];
if (_chkBox.Checked == true)
{
_temp.Add(Convert.ToInt32(item.GetDataKeyValue(this.DataKeyNames[0].ToString())));
}
//String str = item["ColumnUniqueName"].Text;
}
_grdDataListView.MasterTableView.AllowPaging = true;
_grdDataListView.Rebind();
i also try ,but my check box state is not getting after the rebind .. please provide any example or link .
Thank You .
I am also facing the same issues , and i worked with your provided solution it doesn't work for me ,
| foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
| { |
| CheckBox chk = (CheckBox)item["ClientSelectColumn"].Controls[0]; |
| if (chk.Checked) |
| { |
| // your code |
| } |
| } |
_grdDataListView.MasterTableView.AllowPaging = false;
_grdDataListView.Rebind();
int aas = _grdDataListView.Items.Count;
foreach (GridDataItem item in _grdDataListView.MasterTableView.Items)
{
CheckBox _chkBox = (CheckBox)item["ClientSelectColumn"].Controls[0];
if (_chkBox.Checked == true)
{
_temp.Add(Convert.ToInt32(item.GetDataKeyValue(this.DataKeyNames[0].ToString())));
}
//String str = item["ColumnUniqueName"].Text;
}
_grdDataListView.MasterTableView.AllowPaging = true;
_grdDataListView.Rebind();
i also try ,but my check box state is not getting after the rebind .. please provide any example or link .
Thank You .
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2012, 07:31 AM
Hi,
I am not sure about your requirement. Please take a look into the following code snippet I tried to persist the Check state of the ClientSelectColumn.
C#:
Thanks,
Shinu.
I am not sure about your requirement. Please take a look into the following code snippet I tried to persist the Check state of the ClientSelectColumn.
C#:
protected void Button1_Click(object sender, EventArgs e){ _grdDataListView.AllowPaging = false; _grdDataListView.Rebind(); foreach (GridDataItem item in _grdDataListView.Items) { CheckBox chk = (CheckBox)item["ClientSelectColumn"].Controls[0]; if (chk.Checked) { //your code } _grdDataListView.AllowPaging = true; _grdDataListView.Rebind(); ArrayList selectedItems; if (Session["selectedItems"] == null) { selectedItems = new ArrayList(); } else { selectedItems = (ArrayList)Session["selectedItems"]; } foreach (GridDataItem dataItem in _grdDataListView.Items) { string productID = dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["DatakeyName"].ToString(); selectedItems.Add(productID); Session["selectedItems"] = selectedItems; } } }protected void _grdDataListView_PreRender(object sender, EventArgs e){ if (Session["selectedItems"] != null) { ArrayList selectedItems = (ArrayList)Session["selectedItems"]; Int16 stackIndex; for (stackIndex = 0; stackIndex <= selectedItems.Count - 1; stackIndex++) { string curItem = selectedItems[stackIndex].ToString(); foreach (GridItem item in _grdDataListView.MasterTableView.Items) { if (item is GridDataItem) { GridDataItem dataItem = (GridDataItem)item; if (curItem.Equals(dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["DatakeyName"].ToString())) { dataItem.Selected = true; break; } } } } }}Thanks,
Shinu.
0
Rohan
Top achievements
Rank 1
answered on 23 Nov 2012, 08:15 AM
Hi shinu ,
Thank you for you replay...
I just want to get the all selected rows of radgrid , after using this code
rebind radgrid i am getting selected row become false ..
check box values are false ....
but if you are not use
Thank you for you replay...
I just want to get the all selected rows of radgrid , after using this code
_grdDataListView.AllowPaging = false;
_grdDataListView.Rebind(); foreach (GridDataItem item in _grdDataListView.Items) { CheckBox chk = (CheckBox)item["ClientSelectColumn"].Controls[0]; if (chk.Checked) { check box values are false ....
but if you are not use
_grdDataListView.Rebind(); then i am getting the value of check box .. but it only gets the value of last page if radgrid . how can i get all selected rows of radgrid, for select and deselect i am using GridClientSelectColumn column.