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

HighLight Selected Row on PostBack

6 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 18 Sep 2008, 06:09 PM
I have a grid that a user can select a single row.  If they select a row and press a button I have on the page to update that row in the code behind I would like to have that row still highlighted on the postback. 

How can I find the row and set it to selected upon a postback?

6 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 19 Sep 2008, 07:24 AM
Hi Mike,

In order to get reference to the selected item(s) in the grid, you can use the SelectedItems collection fo the control. Furthermore, if you would like to keep the selection after you update the record and rebind the grid to reflect the changes, consider one of the approaches presented in these help articles:

Persist the selected rows client-side

Persist the selected rows server-side

Best,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 19 Sep 2008, 12:44 PM
It would be great not to have those columns for select and deselect.  Is there a way when I perform a post back that the selected row is captured?
0
Sebastian
Telerik team
answered on 19 Sep 2008, 12:50 PM
Hello Mike,

Have you reviewed the first article linked in my post? It illustrates how to retain the selected items with pure client-side selection (where no postback or Select/Deselect buttons are needed). I hope it suits your needs.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 19 Sep 2008, 12:57 PM
Stephen,

Thanks for the quick response, I am always doing a post back so the Server Side would suit me more.  I tried the client one and it loses the selection when doing a postback.

Also, I am using the select row to change the order of the row.  If a user selects a row and presses the move up button I want the selected row to remain highlighted as it moves up.  The same applies if the user selects move to top of the grid. 

You example works well for maintaining the selected row in it's current position.
0
Sebastian
Telerik team
answered on 19 Sep 2008, 01:09 PM
Hello Mike,

The paging/sorting/grouping/filtering functionality (enabled in the example) triggers postback request - am I missing something? I tested it once again and the selection was retained when each of these operations took place.

Regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 19 Sep 2008, 01:32 PM
Your example maintains the selected row which it is intended to do.  I needed to move rows and maintain the selection.  I used a session like your example and just set it to keep track of the row when moving up and down.  It works like a charm. 

Thanks!


Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Mike
Top achievements
Rank 1
Share this question
or