Finding records in RadGrid Telerik with pagination

asp.nettelerik

How is it possible to find given record by key in the radGrid when pagination is enabled ? After insert of an element I would like to select new row that why I need this functionality.

thanks for any help

Best Answer

One way is to disable paging, then make a Rebind, then iterate through all the items, find the page the item should be in and then enable paging. The other way is to make separate Rebind per page, like this:

int count = RadGrid1.MasterTableView.PageCount;  
for (int i = 0; i < count; i++) 
{ 
    RadGrid1.CurrentPageIndex = i; 
    RadGrid1.Rebind();

    foreach (GridDataItem dataItem in RadGrid1.Items) 
    { 
        var yourID = dataItem.GetDataKeyValue("YourID"); 
        if (yourID == insertedItemID)
           break;
    }  
}     
RadGrid1.Rebind(); 

For more info and an example, check the Telerik forums. This links are useful: