Export (0) Print
Expand All

PagerSettings.Mode Property

Gets or sets the mode in which to display the pager controls in a control that supports pagination.

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

public PagerButtons Mode { get; set; }

Property Value

Type: System.Web.UI.WebControls.PagerButtons
One of the PagerButtons values. The default is PagerButtons.Numeric.

ExceptionCondition
ArgumentOutOfRangeException

The Mode is set to a value that is not one of the PagerButtons values.

Controls that support pagination provide multiple modes in which to display the paging controls. Use the Mode property to specify the mode. The following table describes the different modes for pagination controls.

Mode

Description

NextPrevious

Previous-page and next-page buttons.

NextPreviousFirstLast

Previous-page, next-page, first-page, and last-page buttons.

Numeric

Numbered link buttons to access pages directly.

NumericFirstLast

Numbered and first-link and last-link buttons.

When the Mode property is set to the NextPrevious, NextPreviousFirstLast, or NumericFirstLast value, you can specify custom text for the non-numeric buttons by setting the properties shown in the following table.

Property

Description

FirstPageText

Text for the first-page button.

PreviousPageText

Text for the previous-page button.

NextPageText

Text for the next-page button.

LastPageText

Text for the last-page button.

As an alternative, you can also display images for the non-numeric buttons by setting the properties shown in the following table.

Property

Description

FirstPageImageUrl

The URL to an image to display for the first-page button.

PreviousPageImageUrl

The URL to an image to display for the previous-page button.

NextPageImageUrl

The URL to an image to display for the next-page button.

LastPageImageUrl

The URL to an image to display for the last-page button.

NoteNote

When an image property is set, the corresponding text property acts as the alternate text for the image. For example, when the FirstPageImageUrl property is set, the text that is specified by the FirstPageText property is displayed as the alternate text for the image. On browsers that support ToolTips, this text is also displayed as a ToolTip for the corresponding button.

The value of this property is stored in view state.

The following code example demonstrates how to use the Mode property to specify that the pager row for a GridView control should display numeric buttons.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>PagerSetting Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>PagerSetting Example</h3>

        <asp:gridview id="CustomerGridView"
          datasourceid="CustomerDataSource"
          autogeneratecolumns="true"
          datakeynames="CustomerID"  
          allowpaging="true"
          runat="server">

          <pagersettings mode="NumericFirstLast"
            firstpagetext="First"
            lastpagetext="Last"
            pagebuttoncount="5"  
            position="Bottom"/> 

        </asp:gridview>

        <br/>

        <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>

        <!-- 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="CustomerDataSource"
          selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
          connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
          runat="server"/>

      </form>
  </body>
</html>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft