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

Grid.SelectedItems is always 0

1 Answer 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 18 Sep 2013, 02:07 PM
First:
I'm using an .ascx web user control that gets loaded OnInit with ViewState turned off entirely on the web app due to other issues(not related to this post).

Second:
The radgrid is programatically adding the columns based on the folder selected in the tree on the left. When I select a row and hit a button to perform an action my RadGrid1.SelectedItems.Count = 0?

I'm using the same methods to get these types of values on other pages with the only major difference being the columns are added into the markup and not via the codebehind.

Here's 2 examples. 1 is a grid that's working and 1 is the one created programatically. You can see there's an extra GUID or something in the name.

1. Grid that's working's Checkbox:(RadGrid1)
id="ctl00_ctl00_mc_cpMain_C3823986-1DC5-48B4-A950-516AF5401F9D_RadGrid1_ctl00_ctl24_columnSelectCheckBox"

2. Grid that's not working's checkbox: (grdProjectFolderContent)
id="ctl00_ctl00_mc_cpMain_C3823986-1DC5-48B4-A950-516AF5401F9D_CAA11BE1-D9B5-412D-B2C5-F747BFA04B6E_grdProjectFolderContent_ctl00_ctl04_columnSelectCheckBox"

I understand that with ViewState being turned off for the web application I've lost a lot of the information that makes my life a bit easier but unfortunately it had to be that way and I'm guessing this is jst one of the issues I'll face as I start my regression testing. 
Any help is appreciated. Thanks.

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 23 Sep 2013, 07:22 AM
Hi Jay,

I am not completely sure why the SelectedItems collection is always empty without your code declaration. I prepared a small sample and on my side seems to work correctly. I would recommend you to examine our help topics which elaborate more on programmatic creation of RadGrid.
Creating a RadGrid Programmatically
Changing the Grid Structure Dynamically on Postback

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or