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

[Solved] How To Select First Row of Detail Grid in Master/Detail Grid on PreRender?

2 Answers 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jgill
Top achievements
Rank 1
jgill asked on 05 Oct 2009, 04:56 PM

I’m having a problem with the selection of rows in a Master/Detail Grid.

 

Scenario: I have a page with two grids that are connected via a Master/Detail relationship.  It is similar to http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultcs.aspx, except I have two grids instead of three and my page’s pre-render event codebehind looks like:


Protected Sub Page_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.PreRender  
            If RadGrid1.SelectedIndexes.Count = 0 Then 
                RadGrid1.SelectedIndexes.Add(0)  
            End If 
        End Sub 

 

When the page loads for the first time, the first row in the Master grid is selected, but not the first row in the Detail grid. 

 

I wanted to know how to select the first row in the Detail Grid of a Master/Detail Grid on the first load of the page if the Detail grid has any rows related to that particular Master grid item at Index(0).

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Oct 2009, 07:38 AM
Hi Jgill,

Try the following code snippet:

VB:
 
Protected Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As EventArgs) 
    If RadGrid1.SelectedIndexes.Count = 0 Then 
        RadGrid1.MasterTableView.Items(0).Selected = True 
        RadGrid1.MasterTableView.Items(0).ChildItem.NestedTableViews(0).Items(0).Selected = True 
    End If 
End Sub 

-Shinu.
0
jgill
Top achievements
Rank 1
answered on 08 Oct 2009, 03:18 PM
Hi Shinu,
Thank you.  The grids are actually not nested.  There is a RadGrid1 and RadGrid two that are related to each other in a Master/Detail relationship.
Tags
Grid
Asked by
jgill
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
jgill
Top achievements
Rank 1
Share this question
or