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

Set First Row Selected RadGrid

10 Answers 960 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashwin Deshpande
Top achievements
Rank 1
Ashwin Deshpande asked on 17 Sep 2009, 01:23 PM
I Want to set the first row selected of radgrid on Page Load,Sorting etc....Except the Edit Command...

Bcoz when i direclty cick on edit button in radgrid without selecting the row it shows radgrid.selectedvalue is NULL.....

Please help me on this..

10 Answers, 1 is accepted

Sort by
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 17 Sep 2009, 01:45 PM
Hi Ashwin,

You can execute this code to select the first row :
if (RadGrid1.MasterTableView.Items.Count > 0)  
    RadGrid1.MasterTableView.Items[0].Selected = true
0
Ashwin Deshpande
Top achievements
Rank 1
answered on 17 Sep 2009, 01:58 PM

The code given by you doesn't work.....i even tried this...

 

 

If RadGrid1.SelectedIndexes.Count <= 0 Then

 

 

 

 

RadGrid1.SelectedIndexes.Add(0)

 

End If

 



but when i Click on sort in header again grid doesn;t contain any selected row....
0
Casey
Top achievements
Rank 1
answered on 17 Sep 2009, 02:11 PM
When are you executing that code? Have you tried executing that code in the DataBound event of the RadGrid?
0
Warren
Top achievements
Rank 1
answered on 17 Sep 2009, 03:52 PM
You can put this code on PreRender event.

But also, you have to check if render event is fired because user has selected a row.

Create a global Flag called IsSelectedIndexChangedFired and set it to false.

In SelectedIndexChanged event set this flag to true.

No, in PreRender check if this flag is set to true, then do not select first row, else do it.
0
Brian
Top achievements
Rank 1
answered on 24 Mar 2011, 03:20 PM
ItemDataBound does not have any records in the grid. So this will not work. 

Pre-render also doesn't have records as the grid renders first, then the data is bound.

So which event can we tap into which already has the rows loaded?



Please note our request on these threads:

http://www.telerik.com/community/forums/aspnet-ajax/grid/request-new-property-for-autorow-select.aspx

http://www.telerik.com/community/forums/aspnet-ajax/grid/request-new-grid-event-for-onload.aspx 
0
Mira
Telerik team
answered on 28 Mar 2011, 03:43 PM
Hello Warren,

I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented on PreRender. You can find it attached to this message.

I hope this helps.

Best wishes,
Mira
the Telerik team
0
Karthik
Top achievements
Rank 1
answered on 04 Apr 2013, 10:35 AM
Hi guy's,

M using rad grid first row selection procedure

Here i encountered with a new problem, when m selecting new row apart form 1st row and then navigating to another page in grid
the first row is getting selected along with the previous row selected in previous page

Please HELP   
0
Eyup
Telerik team
answered on 09 Apr 2013, 08:30 AM
Hi Karthik,

Can you please verify that you have added the !IsPostBack condition before making the selection?

Regards,
Eyup
the Telerik team
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 their blog feed now.
0
Karthik
Top achievements
Rank 1
answered on 09 Apr 2013, 09:00 AM
Hi Eyup,

I'm binding data to rad grid through "STATIC" Page methods and selection of rows is completely in JavaScript functions
 
0
Eyup
Telerik team
answered on 15 Apr 2013, 07:54 AM
Hi Karthik,

I have prepared a sample RadGrid web site to test the described behavior. Can you please check out the attached application and verify that selecting the first item on initial load is working as expected?

Kind regards,
Eyup
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Ashwin Deshpande
Top achievements
Rank 1
Answers by
Jeroen Eikmans
Top achievements
Rank 1
Ashwin Deshpande
Top achievements
Rank 1
Casey
Top achievements
Rank 1
Warren
Top achievements
Rank 1
Brian
Top achievements
Rank 1
Mira
Telerik team
Karthik
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or