Export (0) Print
Expand All

PagerSettings.Mode Property

Note: This property is new in the .NET Framework version 2.0.

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 */
public PagerButtons get_Mode ()

/** @property */
public void set_Mode (PagerButtons value)

public function get Mode () : PagerButtons

public function set Mode (value : PagerButtons)

Property Value

One of the PagerButtons values. The default is PagerButtons.Numeric.

Exception typeCondition

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#" %>

<html>
  <body>
    <form 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>


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft