NextPreviousPagerField Class
Collapse the table of content
Expand the table of content

NextPreviousPagerField Class

Represents a field that displays navigation controls in a DataPager control enable users to page through data.

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 NextPreviousPagerField : DataPagerField

The NextPreviousPagerField class represents a field that displays navigation controls in a DataPager control. These navigation controls can be used to page through data that are displayed by a control that implements the IPageableItemContainer interface, such as the ListView control.

The NextPreviousPagerField class provides buttons that enable users to navigate through the pages of data one page at a time, or to jump to the first or last page of data.

You can customize the appearance of the NextPreviousPagerField object by using the ButtonCssClass property to set the style of the buttons. You can also use the ButtonType property to choose the type of button that is displayed. The following table lists the available button types.

Button type



A Button control.


An ImageButton control.


A LinkButton control.

You can hide a NextPreviousPagerField object in a DataPager control by setting the Visible property to false. You can also hide the individual buttons (the first-page, previous-page, next-page, and last-page buttons) by setting the ShowFirstPageButton, ShowPreviousPageButton, ShowNextPageButton, and ShowLastPageButton properties to false.

The NextPreviousPagerField control enables you to specify custom text for each button by using the FirstPageText, PreviousPageText, NextPageText, and LastPageText properties.

When the ButtonType property is set to ButtonType.Image, you must provide the URL to an image that will be displayed for the button. You can set images individually for each button by setting the FirstPageImageUrl, PreviousPageImageUrl, NextPageImageUrl, and LastPageImageUrl properties.

When the ButtonType property is set to ButtonType.Image, the corresponding text property acts as the alternate text for the image. For example, the text that is specified by the FirstPageText property is displayed as the alternate text for the first-page image button. In browsers that support tooltips, this text is also displayed as a tooltip.

The following example shows how to use a NextPreviousPagerField 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>NextPreviousPagerField Example</title>
    <form id="form1" runat="server">

      <h3>NextPreviousPagerField Example</h3>

      <asp:ListView ID="ContactsListView" 
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
          <tr runat="server">
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />

      <asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
          <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true" />

      <!-- 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

Community Additions

© 2015 Microsoft