RadGrid for ASP.NET

Basic paging Send comments on this topic.
Paging > Basic paging

Glossary Item Box

When displaying a large set of data in web applications it is a common practice that only a small sub-set of the data at a time would be transferred to the client and operated with. Telerik RadGrid supports this functionality automatically and also provides a set of events, helper methods and properties if the paging operation requires custom intervention.

Set the RadGrid.AllowPaging property to true (default is false) to have Telerik RadGrid handle paging.
Set the RadGrid.AllowCustomPaging property to true if you want to handle paging in a custom manner, or leave it to its default value - false - to allow Telerik RadGrid handle paging automatically.

Note that using custom paging in your Telerik RadGrid may affect the grouping functionality. Additional details are available here.

If paging is enabled, Telerik RadGrid will render pager item(s) (GridPagerItem) on the top and/or bottom of each GridTableView displayed in the hierarchy.
Pager

In order to display the grid pager regardless of the number of records returned and the page size, you should set the PagerStyle -> AlwaysVisible property of the corresponding GridTableView to true. Its default value is false.
Till version 3.5.2 Telerik RadGrid will not show the Pager, when the number of displayed Items is less than the page size.
However, if you still want to show a Pager row in such cases, we recommend using a CommandItem that mimics the Pager row:
ASPX/ASCX Copy Code
<MasterTableView CommandItemDisplay="Bottom">
 
<CommandItemTemplate>
      
<% if (RadGrid1.MasterTableView.PageCount == 1) %>
      
<% { %>
      
<div style="height:20px;background-color:ButtonFace;">
           
Change page: < > | Displaying page 1 of <%= RadGrid1.MasterTableView.PageCount %>,
           items 1 to
<%= RadGrid1.MasterTableView.Items.Count %>
           
of <%= (RadGrid1.MasterTableView.Items.Count)*RadGrid1.MasterTableView.PageCount %>.
      
</div>
      
<% } %>
 
</CommandItemTemplate>
 
<PagerStyle Height="20px" BackColor="ButtonFace"/>
</
MasterTableView>

You can get the exact numbers of rows in your RadGrid either directly from the DataSource or in the following manner in the ItemDataBound event:

C# Copy Code
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
        
if (e.Item is GridPagerItem)
       {
        Label1.Text = (e.Item
as GridPagerItem).Paging.DataSourceCount.ToString();
       }
   }

VB.NET Copy Code
Protected Sub RadGrid1_ItemDataBound(ByVal sender as Object, ByVal e as GridItemEventArgs)
    If TypeOf e.Item Is GridPagerItem Then
         Label1.Text = CType(e.Item, GridPagerItem).Paging.DataSourceCount.ToString()
    EndIf
End Sub

or in the ASPX like this:

ASPX/ASCX Copy Code
 <PagerTemplate>
           
<%# (Container as GridPagerItem).Paging.DataSourceCount %>
  
</PagerTemplate>