2012-06-13 32 views

回答

1

請嘗試使用以下代碼片段。

private int totalItemCount; 
protected void RadGrid1_ItemEvent(object sender, GridItemEventArgs e) 
{ 
    if (e.EventInfo is GridInitializePagerItem) 
    { 
     totalItemCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount; 
    } 
} 
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

謝謝。沒有分頁的重新綁定是有幫助的,但我有超過350頁和7k +的項目,所以它不是很好的移動我的網格。 – IgorCh