I am executing the code below following a refresh from the database. What I'm trying to make happen is that after a process completes to update one of the rows, the data is refreshed and the previously selected record is still selected for the user and scrolled into view. When I execute this code following an update routine the grid is scrolled completely to the bottom, and both the record I selected and the visible row within the grid (even though it is now a different row) is selected. If I execute it from a command button, the first record is selected and the grid is scrolled completely to the top. What am I doing wrong?
datagridview1.DataSource = Nothing
datagridview1.DataSource = Log_Table
If Log_Table.Rows.Count > 0 Then
' Log_Rec = Log_Table.First
Dim Row As Telerik.WinControls.UI.GridViewRowInfo
For Each Row In datagridview1.Rows
If Row.Cells("Rec_ID").Value = RecID Then
Row.IsSelected = True
Else
Row.IsSelected
= False
End If
Next
For Each Row In datagridview1.Rows
If Row.IsSelected Then
Row.EnsureVisible()
End If
Next
End If