简体   繁体   English

如何获得radgrid上的页数计数

[英]How to get the number of pages count on radgrid

How can I get the number of pages in a RadGrid through code? 如何通过代码获取RadGrid的页面数? I tried the following but it always returned 1, although there are 10 pages. 我尝试了以下操作,但始终返回1,尽管有10页。

mygridView.PageCount.ToString();

I also tried the following 我也尝试了以下

mygridView.MasterTableView.PageCount.ToString();

I got the same result. 我得到了相同的结果。 The Rad Grid has AllowPaging= "true" Rad网格的AllowPaging= "true"

Basically all I want is to display in a label, "There are currently 300 records in 2 of 10 pages." 基本上,我只想在标签上显示“当前10页中的2页有300条记录”。

I need to get the "10" from the total pages in the RadGrid . 我需要从RadGrid的总页数中获取“ 10”。

Thank you 谢谢

 protected void RadGrid1_PreRender(object sender, EventArgs e)   {
   string str = RadGrid1.PageCount.ToString();   }

Let me know if any concern. 让我知道是否有任何问题。

 Protected Sub grid_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles grid.ItemDataBound
        If TypeOf e.Item Is GridPagerItem Then
            ' -- Dim summaryCount as integer
            summaryCount += CType(e.Item, GridPagerItem).Paging.DataSourceCount.ToString()
        End If
    End Sub

You need to tell the grid how many records there are in total. 您需要告诉网格总共有多少条记录。 This is done by setting the grid's VirtualItemCount property (you will have to query the total number of records). 这是通过设置网格的VirtualItemCount属性来完成的(您将必须查询记录的总数)。

For details, have a look at the documentation page or refer to the online demo for custom paging. 有关详细信息,请查看文档页面或参考在线演示以进行自定义分页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM