当结果网格有多个页面时,如何在过滤后获取RadGrid的行数。
radGrid.MasterTableView.Items.Count
在这种情况下,返回页面大小。
答案 0 :(得分:1)
如果启用了分页,则items.Count将仅显示页面大小。你可以做的一件事是将分页设置为false,绑定网格,获取计数,将分页设置为true,然后重新绑定网格。
RadGrid1.MasterTableView.AllowPaging = false;
RadGrid1.MasterTableView.Rebind();
int totalCount = RadGrid1.MasterTableView.Items.Count;
RadGrid1.MasterTableView.AllowPaging =true;
RadGrid1.MasterTableView.Rebind();
您可以做的另一件事是通过计算ItemDataBound网格事件中的GridDataItem项来获取计数。
有关详情,请参阅此Telerik help page。
答案 1 :(得分:1)
请尝试使用以下代码段。
private int totalItemCount;
protected void RadGrid1_ItemEvent(object sender, GridItemEventArgs e)
{
if (e.EventInfo is GridInitializePagerItem)
{
totalItemCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;
}
}