RadGrid for ASP.NET

RadGrid Send comments on this topic.
PageCount Property
See Also  Example
Telerik.WebControls Namespace > RadGrid Class : PageCount Property


Gets the number of pages required to display the records of the data source in a Telerik RadGrid control.

  

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property PageCount As Integer
Visual Basic (Usage)Copy Code
Dim instance As RadGrid
Dim value As Integer
 
value = instance.PageCount
C# 
public int PageCount {get;}

Return Value

The number of pages in a Telerik RadGrid control.

Example

The following code example demonstrates how to use the PageCount property to determine the total number of pages displayed in the Telerik RadGrid control.
C#Copy Code
<%@ Page Language="C#" %>

<%@ Register Assembly=
"RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat=
"server">
   
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       Label1.Text = RadGrid1.PageCount.ToString();
   }
</script>

<html xmlns=
"http://www.w3.org/1999/xhtml" >
<head runat=
"server">
   <title>Untitled Page</title>
</head>
<body>
   <form id=
"form1" runat="server">
   <div>
       <rad:RadGrid
           DataSourceID=
"SqlDataSource1"
           
ID="RadGrid1"
           
AllowPaging="true"
           
runat="server" OnPreRender="RadGrid1_PreRender">
       </rad:RadGrid>
       <!-- This example uses Microsoft SQL Server and connects  -->
       <!-- to the Northwind sample database. Use an ASP.NET     -->
       <!-- expression to retrieve the connection
string value   -->
       <!-- from the Web.config file.                            -->        
       <asp:SqlDataSource
           ID=
"SqlDataSource1"
           
runat="server"
           
ConnectionString="<<see cref="!:NorthwindConnectionString">$ ConnectionStrings</see>>"
           
SelectCommand="SELECT [CustomerID], [ContactName], [CompanyName] FROM [Customers]">
       </asp:SqlDataSource>
       <asp:Label ID=
"Label1" runat="server" Text="Label"></asp:Label></div>
   </form>
</body>
</html>
    
Visual BasicCopy Code
<%@ Page Language="VB" <see cref="!:> <"/>@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<!DOCTYPE html Public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = RadGrid1.PageCount.ToString()
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <rad:RadGrid
            DataSourceID="SqlDataSource1"
            ID="RadGrid1"
            AllowPaging="true"
            runat="server" OnPreRender="RadGrid1_PreRender" >
        </rad:RadGrid>
        <!-- This example uses Microsoft SQL Server And connects -->
        <!-- To the Northwind sample database. Use an ASP.NET -->
        <!-- expression To retrieve the connection String value -->
        <!-- from the Web.config file. -->
        <asp:SqlDataSource
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<<see cref="!:NorthwindConnectionString">$ ConnectionStrings</see>>"
            SelectCommand="SELECT [CustomerID], [ContactName], [CompanyName] FROM [Customers]">
        </asp:SqlDataSource>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
    
</body>
</html>

Remarks

When the paging feature is enabled (by setting the AllowPaging property to true), use the PageCount property to determine the total number of pages required to display the records in the data source. This value is calculated by dividing the total number of records in the data source by the number of records displayed in a page (as specified by the PageSize property) and rounding up.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also