PagerSettings 类

定义

表示支持分页的控件中的分页控件的属性。Represents the properties of the paging controls in a control that supports pagination. 此类不能被继承。This class cannot be inherited.

public ref class PagerSettings sealed : System::Web::UI::IStateManager
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public sealed class PagerSettings : System.Web.UI.IStateManager
type PagerSettings = class
    interface IStateManager
Public NotInheritable Class PagerSettings
Implements IStateManager
继承
PagerSettings
属性
实现

示例

下面的代码示例演示如何使用PagerSettings PagerSettings属性中包含的对象自定义在GridView控件的页导航行中显示的按钮的文本。The following code example demonstrates how to use the PagerSettings object that is contained in the PagerSettings property to customize the text of the buttons that are displayed in the pager row of a GridView control.


<%@ 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="NextPreviousFirstLast"
            firstpagetext="First"
            lastpagetext="Last"
            nextpagetext="Next"
            previouspagetext="Prev"   
            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="NextPreviousFirstLast"
            firstpagetext="First"
            lastpagetext="Last"
            nextpagetext="Next"
            previouspagetext="Prev"   
            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>

注解

支持分页的控件( GridView如、 DetailsViewFormView控件)可以显示一组称为 "页导航" 的控件,该控件允许用户在控件中导航页面。Controls that support pagination (such as the GridView, DetailsView, and FormView controls) can display a set of controls called the pager that allows the user to navigate the pages within the control. 这些控件使用类来表示页导航的属性。 PagerSettingsThe PagerSettings class is used by these controls to represent the properties of the pager. 通常, PagerSettings对象存储PagerSettings在控件的属性中。In general, the PagerSettings object is stored in the PagerSettings property of the control. 可以通过设置PagerSettings对象的属性来自定义页导航。You can customize the pager by setting the properties of the PagerSettings object.

寻呼支持多种不同的显示模式。The pager supports several different display modes. 若要指定页导航的显示模式,请设置Mode属性。To specify the mode in which to display the pager, set the Mode property. 下表描述了不同的模式。The following table describes the different modes.

模式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-link, first-link, and last-link buttons.

当属性设置NextPrevious为、或NextPreviousFirstLast NumericFirstLast值时,您可以通过设置下表中显示的属性来自定义非数值按钮的文本。 ModeWhen the Mode property is set to the NextPrevious, NextPreviousFirstLast, or NumericFirstLast value you can customize the text of the non-numeric buttons by setting the properties shown in the following table.

PropertyProperty 说明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 as shown in the following table.

PropertyProperty 说明Description
FirstPageImageUrl 为第一页按钮显示的图像的 URL。The URL to an image to display for the first-page button.
PreviousPageImageUrl 为上一页按钮显示的图像的 URL。The URL to an image to display for the previous-page button.
NextPageImageUrl 为下一页按钮显示的图像的 URL。The URL to an image to display for the next-page button.
LastPageImageUrl 为最后一页按钮显示的图像的 URL。The URL to an image to display for the last-page button.

备注

设置 image 属性后,相应的文本属性将充当图像的替换文字。When an image property is set, the corresponding text property acts as the alternate text for the image. 例如,设置FirstPageImageUrl属性后, FirstPageText属性指定的文本将显示为图像的替换文字。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.

当属性设置Numeric为或NumericFirstLast值时,可以通过设置PageButtonCount属性来指定要在页导航中显示的页按钮的数量。 ModeWhen the Mode property is set to the Numeric or NumericFirstLast value, you can specify the number of page buttons to display in the pager by setting the PageButtonCount property.

页导航可显示在控件的顶部、底部或同时显示在顶部和底部。The pager can be displayed at the top, the bottom, or both the top and bottom of a control. 若要指定页导航的位置,请设置Position属性。To specify the position of the pager, set the Position property. 若要显示或隐藏页导航,请Visible使用属性。To show or hide the pager, use the Visible property.

构造函数

PagerSettings()

初始化 PagerSettings 类的新实例。Initializes a new instance of the PagerSettings class.

属性

FirstPageImageUrl

获取或设置为第一页按钮显示的图像的 URL。Gets or sets the URL to an image to display for the first-page button.

FirstPageText

获取或设置为第一页按钮显示的文字。Gets or sets the text to display for the first-page button.

LastPageImageUrl

获取或设置为最后一页按钮显示的图像的 URL。Gets or sets the URL to an image to display for the last-page button.

LastPageText

获取或设置为最后一页按钮显示的文字。Gets or sets the text to display for the last-page button.

Mode

获取或设置支持分页的控件中的页导航控件的显示模式。Gets or sets the mode in which to display the pager controls in a control that supports pagination.

NextPageImageUrl

获取或设置为下一页按钮显示的图像的 URL。Gets or sets the URL to an image to display for the next-page button.

NextPageText

获取或设置为下一页按钮显示的文字。Gets or sets the text to display for the next-page button.

PageButtonCount

获取或设置在 Mode 属性设置为 NumericNumericFirstLast 值时页导航中显示的页按钮的数量。Gets or sets the number of page buttons to display in the pager when the Mode property is set to the Numeric or NumericFirstLast value.

Position

获取或设置一个值,该值指定页导航的显示位置。Gets or sets a value that specifies the location where the pager is displayed.

PreviousPageImageUrl

获取或设置为上一页按钮显示的图像的 URL。Gets or sets the URL to an image to display for the previous-page button.

PreviousPageText

获取或设置为上一页按钮显示的文字。Gets or sets the text to display for the previous page button.

Visible

获取或设置一个值,该值指示是否在支持分页的控件中显示分页控件。Gets or sets a value indicating whether the paging controls are displayed in a control that supports pagination.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

检索 PagerSettings 对象的字符串表示形式。Retrieves the string representation of a PagerSettings object.

事件

PropertyChanged

PagerSettings 对象的属性更改值时发生。Occurs when a property of a PagerSettings object changes values.

显式界面实现

IStateManager.IsTrackingViewState

获取一个值,该值指示服务器控件是否在跟踪其视图状态更改。Gets a value that indicates whether the server control is tracking its view state changes.

IStateManager.LoadViewState(Object)

加载以前保存的 PagerSettings 对象的视图状态。Loads the previously saved view state of the PagerSettings object.

IStateManager.SaveViewState()

保存 PagerSettings 对象的当前视图状态。Saves the current view state of the PagerSettings object.

IStateManager.TrackViewState()

标记开始跟踪并将视图状态更改保存到 PagerSettings 对象的起始点。Marks the starting point at which to begin tracking and saving view state changes to the PagerSettings object.

适用于

另请参阅