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

[Solved] Highlighting First Row of Each Grid

1 Answer 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 26 Feb 2008, 10:11 AM
Hi

I've got 3 grids on a page and on the load of the page I can highlight the first row of each grid using the following code.  I'll mention here that the Leave and Cost grid both relate to the ID of the Employees grid.


'select the first row in every page if no row selected

Protected Sub radgridEmployees_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles radgridEmployees.PreRender

If radgridEmployees.SelectedIndexes.Count = 0 Then

If radgridEmployees.Items.Count > 0 Then

radgridEmployees.SelectedIndexes.Add(0)

radgridEmployee_Costs.DataBind()

If radgridEmployee_Costs.Items.Count > 0 Then

radgridEmployee_Costs.SelectedIndexes.Add(0)

End If

radgridEmployee_Leave.DataBind()

If radgridEmployee_Leave.Items.Count > 0 Then

radgridEmployee_Leave.SelectedIndexes.Add(0)

End If

End If

End If

End Sub

I can however get the 1st row of the Leave and Costs grids to highlight when I click on a different row in the Employees grid.

What am I missing?  I've tried to use the above code (without the DataBind's) in a number of events but cant seem to get it to work.  Enable Client Side Row Selection is enabled for all the grids.

Thanks

Richard

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 28 Feb 2008, 03:07 PM
Hi Richard,

Calling the DataBind method for any of the grids is not recommended. If you would like to select a row, you can use RadGrid1.MasterTableView.Rows[x].Selected=true. At any point if you would like to rebind the control, you can call its Rebind() method.
I hope this information helps.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or