问题
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
回答1:
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:
- RadGrid - select row on other page
- How to count selected items in RadGrid
- Getting total number of rows in a grid
回答2:
Here is a link from Telerik that will select the Last Updated, or Last Inserted row.
Select last Updated or Inserted row in Telerik RadGrid
回答3:
RadGrid1.AllowPaging = false;
RadGrid1.Rebind();
foreach (GridDataItem dataItem in RadGrid1.Items)
{
var yourID = dataItem.GetDataKeyValue("YourID");
if (yourID == insertedItemID)
break;
}
RadGrid1.AllowPaging = true; RadGrid1.Rebind();
来源:https://stackoverflow.com/questions/8646219/finding-records-in-radgrid-telerik-with-pagination