This is a migrated thread and some comments may be shown as answers.

RadGrid Selectem Items not working

6 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bhupendra
Top achievements
Rank 1
Bhupendra asked on 21 Dec 2011, 11:58 AM
Hi,

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

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Dec 2011, 12:19 PM
Hello,

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.
0
Bhupendra
Top achievements
Rank 1
answered on 21 Dec 2011, 02:12 PM
hi ,

i tried it but still SelectedItems is showing zero items , so i cannot find which rows were selected.
0
Bhupendra
Top achievements
Rank 1
answered on 22 Dec 2011, 01:39 PM
Hi ,

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.


 
0
Rahul
Top achievements
Rank 2
answered on 23 Dec 2011, 05:39 AM
How do you BInd the DataSource of the Grid?(ie,from which portion of the code?from onload or using "NeedDataSource" Event Handler?)
0
Bhupendra
Top achievements
Rank 1
answered on 23 Dec 2011, 11:55 AM
i m using onneeddatasource event of radgrid
0
Rahul
Top achievements
Rank 2
answered on 23 Dec 2011, 12:02 PM

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
Tags
Grid
Asked by
Bhupendra
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bhupendra
Top achievements
Rank 1
Rahul
Top achievements
Rank 2
Share this question
or