简体   繁体   中英

How to get the number of pages count on radgrid

How can I get the number of pages in a RadGrid through code? I tried the following but it always returned 1, although there are 10 pages.

mygridView.PageCount.ToString();

I also tried the following

mygridView.MasterTableView.PageCount.ToString();

I got the same result. The Rad Grid has AllowPaging= "true"

Basically all I want is to display in a label, "There are currently 300 records in 2 of 10 pages."

I need to get the "10" from the total pages in the RadGrid .

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).

For details, have a look at the documentation page or refer to the online demo for custom paging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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