I have a RadGrid which has AllowMultiRowSelect property to true. I have a button and on click of button i need to fetch details of selected rows.
I have wriiten following code on button click
protected void OnButtonClick( object sender,EventArgs e )
{ ArrayList ar = new ArrayList();
foreach (GridDataItem item in RadGridFrom.SelectedItems)
{ ar.Add( item["Column1"].Text);//access the value here
}
}
but SelectedItems collectioin always have O items , I am not able to figure out why this is happening.
I also tried following code for fetching details of selected rows :
protected void OnButtonClick( object sender,EventArgs e )
{
ArrayList ar = new ArrayList();
foreach (GridDataItem item in RadGridFrom.MasterTableView.Items)
{
if (item.Selected)
ar.Add( item["Column1"].Text);//access the value here
}
}
but still it is not working.
I am using Telerik.Web.UI_2011_2_915_Trial dll
Kindly help with the solution ASAP.
Thanks,
Bhupendra
6 Answers, 1 is accepted

Try the following code.
C#:
protected
void
Button2_Click(
object
sender, EventArgs e)
{
foreach
(GridDataItem itm
in
RadGrid1.SelectedItems)
{
string
val = itm[
"Column1"
].Text;
}
}
-Shinu.

i tried it but still SelectedItems is showing zero items , so i cannot find which rows were selected.

I am not using GridBoundColumns Select/Deslect for selecting/deselecting rows. Same Grid is used for drag and drop of rows to another grid.So I cant use select/deselect/checkbox to select rows , I want to select rows in similar way for both drag and drop and also for removing equipments . Plz provide the solution asap i have tried
RadGrid1.SelectedItems collection always gives 0 items. SO i cant find the selected rows.



Try to find out the Selected Rows before the grid is getting rebind when the button click postback occurs,and use that data inside the Button click event handler.
Greetings,
Rahul R