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

Setting SelectedRow/SelectedIndex?

3 Answers 233 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jill-Connie Lorentsen
Top achievements
Rank 1
Jill-Connie Lorentsen asked on 06 Aug 2009, 12:58 PM

I have a GridView into which I load a few rows of data. Behind each row I have more information, which is displayed in a different form when the user clicks on the row. I also have "Previous" and "Next" buttons to navigate in the GridView.

At startup it looks like the first row is selected, it is blue and has a little arrow to the right. But when I click the "Next" button I get radgrid.SelectedRows.Count = 0, and therefore I can't navigate to the next row. If I then click on the first row I get the same result, BUT if I click on one of the other rows I get radgrid.SelectedRows.Count = 1 and everything works fine. I then can click on the first row too, getting the expected result.

Is this a bug, or is it something I'm doing wrong? Is there a way to set which row that is selected, - radgrid.Rows.SelectedIndex = 0 ?

Any help is appreciated.

Regards, 

Jill-Connie Lorentsen

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 06 Aug 2009, 02:40 PM
Hi Jill-Connie Lorentsen,

Thank you for contacting us.

This is not an issue. Initially when RadGridView is loading, no rows are selected. You should click on some row or change the current row to make a row selected. SelectedRows collection contains all selected rows when RadGridView is in multi row selection mode. When using the grid in single selection mode - which is by default - there is only one row that can be selected. I suggest using the CurrentRow property in this case. It contains the currently active row and it is related to the Position property of the corresponding currency manager.

I hope this helps. Should you have any questions, feel free to ask.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jill-Connie Lorentsen
Top achievements
Rank 1
answered on 07 Aug 2009, 07:16 AM
Thanks!

My RadGrid is in multi row selection selection mode, and I want the first row to be selected at startup, so that the user doesn't need to click anything.

I don't use a currency manager, but I solved this by setting:

 

 

radgrid.CurrentRow = radgrid.Rows[0];

 

 

radgrid.CurrentRow.IsSelected = true;

I would have thougth the first line would do the trick, but it doesn't...


Regards, Jill-Connie

 

 
0
Jack
Telerik team
answered on 07 Aug 2009, 08:25 AM
Hi Jill-Connie Lorentsen,

I am glad to hear that you have found a solution. Actually the first line should work when you use our latest release - Q2 2009 SP1. I recommend that you try this new version. It addresses several issues and contains a lot of new features. We will appreciate your feedback. If you have any other questions, don't hesitate to write us back.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Jill-Connie Lorentsen
Top achievements
Rank 1
Answers by
Jack
Telerik team
Jill-Connie Lorentsen
Top achievements
Rank 1
Share this question
or