I use RadDataPager (page size = 10). I want to focus on a specific row. I tried this code:
private
void GV_Results_DataLoaded(object sender, EventArgs e)
{
if (SelectedEntity != null)
V_Result SelectedRow = (
from V_Result r in GV_Results.Items
where r.R_ID.Equals(SelectedEntity.R_ID)
select r).FirstOrDefault();
GV_Results.SelectedItem = SelectedRow;
int selectedIndex = GV_Results.Items.IndexOf(GV_Results.SelectedItem);
if (selectedIndex != -1)
{
int pageIndex = selectedIndex / rpg_results.PageSize;
rpg_results.MoveToPage(pageIndex);
}
}
What happens is, in the data loaded function the grid loads only 10 records in each page index.
so if the wanted row is not in the first page, the SelectedRow is null. (because GV_Results.Items contains only the records that are in the first page).
And if I go to the page that contains the wanted row, the selectedRow is not null, but the selectedIndex will be 5 if the selected item was item number 15, and 7 if the selected index was actualy 27. Because
GV_Results.Items.IndexOf(GV_Results.SelectedItem); again behaves like it has only 10 items.
How can I focus on the selected item if it is not in the firs page?