Editar

Compartir a través de


PagerSettings.Mode Property

Definition

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

public:
 property System::Web::UI::WebControls::PagerButtons Mode { System::Web::UI::WebControls::PagerButtons get(); void set(System::Web::UI::WebControls::PagerButtons value); };
public System.Web.UI.WebControls.PagerButtons Mode { get; set; }
member this.Mode : System.Web.UI.WebControls.PagerButtons with get, set
Public Property Mode As PagerButtons

Property Value

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

Exceptions

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

Examples

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>

<%@ Page language="VB" %>

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

Remarks

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.

Note

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.

Applies to

See also