This documentation is archived and is not being maintained.

NumericPagerField Class

Represents a DataPager field that enables users to select a page by page number.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class NumericPagerField : DataPagerField

The NumericPagerField class displays navigation controls in a DataPager control. The controls can be used to page through data that is displayed by a control that implements the IPageableItemContainer interface, such as the ListView control. The NumericPagerField object displays page numbers as buttons that users can click to move to specific a page. The control also displays next-page and previous-page buttons that enable users to access more pages of data than the ones that are displayed by the control.

You can customize the appearance of the NumericPagerField object by using the properties that are listed in the following table.




The CSS class for the current page number.


The CSS class for the next-page and previous-page buttons.


The CSS class for the buttons that represent the page numbers.

You can use the ButtonType property to select the type of button that will be displayed. The following table lists the available button types.

Button type



A Button control.


An ImageButton control.


A LinkButton control.

The controls inside the NumericButtonCssClass object are rendered with non-breaking spaces between them. If you want to customize this behavior, you can use the RenderNonBreakingSpacesBetweenControls property.

You can hide a NumericPagerField object in a DataPager control by setting the Visible property to false. You cannot control the visibility of the next-page and previous-page buttons. They are displayed by the control if the associated data control has additional pages available to display. You can use the ButtonCount property to specify how many buttons are displayed in a NumericPagerField object. Each button corresponds to a page number.

You can set the text of the next-page button by setting the NextPageText property. You can set the text of the previous-page button by using the PreviousPageText property.

When the ButtonType property is set to ButtonType.Image, you must provide the URL of an image that will be displayed for the next-page and previous page buttons. You do this by setting the NextPageImageUrl and PreviousPageImageUrl properties. In that case, the corresponding text property is used as the alternate text for the image. For example, the text that is specified by the NextPageImageUrl property is displayed as the alternate text for the next-page image button. On browsers that support tooltips, this text is also displayed as a tooltip for the corresponding button.

The following example shows how to use a NumericPagerField object to page through data that is displayed in a ListView control.

<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<html xmlns="" >
  <head id="Head1" runat="server">
    <title>NumericPagerField Example</title>    
    <style type="text/css">
      	text-align: center;
      	font: 12px Arial, Helvetica, sans-serif;
      	padding: 2px 2px 2px 2px;
      	border: 1px solid;
      	width: 500px;
      	padding: 2px 6px;
      	border: solid 1px #ddd; 
      	background: #2E8B57;
      	padding: 2px 6px;
      	border: solid 1px #ddd;
      	text-decoration: none;
      	color: #2E8B57;
      .PageNumber:hover, .PrevNext:hover
      	background-color: #FFA500;
      	color: White;
    <form id="form1" runat="server">

      <h3>NumericPagerField Example</h3>

      <asp:ListView ID="ContactsListView" 
          <table runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
          <tr runat="server">
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
            <td align="left">
              <asp:Label ID="NameLabel" runat="server" 
                Text='<%#Eval("LastName") + ", " + Eval("FirstName")%>' />
      <br />

        <asp:DataPager runat="server" 
              PreviousPageText="&lt; Prev"
              NextPageText="Next &gt;"
              NumericButtonCssClass="PageNumber" />
      <br />

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ContactsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [ContactID], [FirstName], [LastName] 
          FROM Person.Contact">



Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5