NextPreviousPagerField 类

定义

表示一个字段,该字段显示 DataPager 控件中使用户能够分页浏览数据的导航控件。Represents a field that displays navigation controls in a DataPager control enable users to page through data.

public ref class NextPreviousPagerField : System::Web::UI::WebControls::DataPagerField
public class NextPreviousPagerField : System.Web.UI.WebControls.DataPagerField
type NextPreviousPagerField = class
    inherit DataPagerField
Public Class NextPreviousPagerField
Inherits DataPagerField
继承
NextPreviousPagerField

示例

下面的示例演示如何使用 NextPreviousPagerField 对象对控件中显示的数据进行分页 ListViewThe 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"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>NextPreviousPagerField Example</title>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>NextPreviousPagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
            </td>
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

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

      <!-- 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">
      </asp:SqlDataSource>
      
    </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 id="Head1" runat="server">
    <title>NextPreviousPagerField Example</title>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>NextPreviousPagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
            </td>
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

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

      <!-- 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">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

注解

NextPreviousPagerField类表示一个字段,该字段显示控件中的导航控件 DataPagerThe NextPreviousPagerField class represents a field that displays navigation controls in a DataPager control. 这些导航控件可用于对实现接口的控件 IPageableItemContainer (如控件)显示的数据进行分页 ListViewThese 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.

NextPreviousPagerField类提供使用户可以一次在页面上浏览数据的按钮,或跳转到第一个或最后一个数据页。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.

您可以 NextPreviousPagerField 通过使用属性设置按钮的样式来自定义对象的外观 ButtonCssClassYou can customize the appearance of the NextPreviousPagerField object by using the ButtonCssClass property to set the style of the buttons. 你还可以使用 ButtonType 属性来选择所显示的按钮类型。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 说明Description
Button 一个 Button 控件。A Button control.
Image 一个 ImageButton 控件。An ImageButton control.
Link 一个 LinkButton 控件。A LinkButton control.

可以 NextPreviousPagerField DataPager 通过将属性设置为来隐藏控件中的对象 Visible falseYou can hide a NextPreviousPagerField object in a DataPager control by setting the Visible property to false. 还可以通过将 ShowFirstPageButtonShowPreviousPageButtonShowNextPageButtonShowLastPageButton 属性设置为来 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.

NextPreviousPagerField控件使您可以使用 FirstPageTextPreviousPageTextNextPageText 和属性为每个按钮指定自定义文本 LastPageTextThe NextPreviousPagerField control enables you to specify custom text for each button by using the FirstPageText, PreviousPageText, NextPageText, and LastPageText properties.

ButtonType 属性设置为时 ButtonType.Image ,必须提供将为该按钮显示的图像的 URL。When the ButtonType property is set to ButtonType.Image, you must provide the URL to an image that will be displayed for the button. 通过设置 FirstPageImageUrl 、、 PreviousPageImageUrl NextPageImageUrl 和属性,可以为每个按钮单独设置图像 LastPageImageUrlYou can set images individually for each button by setting the FirstPageImageUrl, PreviousPageImageUrl, NextPageImageUrl, and LastPageImageUrl properties.

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

构造函数

NextPreviousPagerField()

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

属性

ButtonCssClass

获取或设置用于在浏览器上呈现页导航字段的按钮的级联样式表 (CSS) 类。Gets or sets the cascading style sheet (CSS) class that is used to render the buttons of the pager field on the browser.

ButtonType

获取或设置要在页导航字段中显示的按钮类型。Gets or sets the button type to display in the pager field.

DataPager

获取对数据页导航的引用,该数据页导航与 DataPagerField 对象关联。Gets a reference to the data pager that the DataPagerField object is associated with.

(继承自 DataPagerField)
FirstPageImageUrl

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

FirstPageText

获取或设置为第一页按钮显示的文本。Gets or sets the text that is displayed for the first-page button.

IsTrackingViewState

获取一个值,该值指示 DataPagerField 对象是否在跟踪其视图状态更改。Gets a value that indicates whether the DataPagerField object is tracking its view-state changes.

(继承自 DataPagerField)
LastPageImageUrl

获取或设置为 NextPreviousPagerField 对象中的最后一页按钮显示的图像的 URL。Gets or sets the URL to an image that is displayed for the last-page button in the NextPreviousPagerField object.

LastPageText

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

NextPageImageUrl

获取或设置为 NextPreviousPagerField 对象中的下一页按钮显示的图像的 URL。Gets or sets the URL to an image that is displayed for the next-page button in the NextPreviousPagerField object.

NextPageText

获取或设置为下一页按钮显示的文本。Gets or sets the text that is displayed for the next-page button.

PreviousPageImageUrl

获取或设置为 NextPreviousPagerField 对象中的上一页按钮显示的图像的 URL。Gets or sets the URL to an image that is displayed for the previous-page button in the NextPreviousPagerField object.

PreviousPageText

获取或设置为上一页按钮显示的文本。Gets or sets the text that is displayed for the previous-page button.

QueryStringHandled

获取或设置一个值,该值指示是否已对查询字符串字段进行计算。Gets or sets a value that indicates whether the query string field has been evaluated.

(继承自 DataPagerField)
QueryStringValue

从请求的 URL 获取查询字符串字段的值。Gets the value of the query string field from the URL of the request.

(继承自 DataPagerField)
RenderDisabledButtonsAsLabels

获取或设置一个值,该值指示禁用的按钮是否由 Label 对象呈现为 NextPreviousPagerField 控件。Gets or sets a value that indicates whether disabled buttons are rendered as Label controls by the NextPreviousPagerField object.

RenderNonBreakingSpacesBetweenControls

获取或设置一个值,该值指示是否在控件之间呈现非换行空格。Gets or sets a value that indicates whether non-breaking spaces are rendered between controls.

ShowFirstPageButton

获取或设置一个值,该值指示第一页按钮是否显示在 NextPreviousPagerField 对象中。Gets or sets a value that indicates whether the first-page button is displayed in a NextPreviousPagerField object.

ShowLastPageButton

获取或设置一个值,该值指示最后一页按钮是否显示在 NextPreviousPagerField 对象中。Gets or sets a value that indicates whether the last-page button is displayed in a NextPreviousPagerField object.

ShowNextPageButton

获取或设置一个值,该值指示下一页按钮是否显示在 NextPreviousPagerField 对象中。Gets or sets a value that indicates whether the next-page button is displayed in a NextPreviousPagerField object.

ShowPreviousPageButton

获取或设置一个值,该值指示上一页按钮是否显示在 NextPreviousPagerField 对象中。Gets or sets a value that indicates whether the previous-page button is displayed in a NextPreviousPagerField object.

ViewState

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原 DataPagerField 对象的视图状态。Gets a dictionary of state information that enables you to save and restore the view state of a DataPagerField object across multiple requests for the same page.

(继承自 DataPagerField)
Visible

获取或设置指示是否呈现数据页导航字段的值。Gets or sets a value that indicates whether a data pager field is rendered.

(继承自 DataPagerField)

方法

CloneField()

创建从 DataPagerField 派生的当前对象的副本。Creates a copy of the current object that is derived from DataPagerField.

(继承自 DataPagerField)
CopyProperties(DataPagerField)

将当前 NextPreviousPagerField 对象的属性复制到指定的 DataPagerField 对象。Copies the properties of the current NextPreviousPagerField object to the specified DataPagerField object.

CreateDataPagers(DataPagerFieldItem, Int32, Int32, Int32, Int32)

为页导航字段对象创建用户界面 (UI) 控件并将它们添加到指定的容器。Creates the user interface (UI) controls for the pager field object and adds them to the specified container.

CreateField()

创建并返回 NextPreviousPagerField 类的新实例。Creates and returns a new instance of the NextPreviousPagerField class.

Equals(Object)

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

GetHashCode()

用作 NextPreviousPagerField 类的哈希函数。Serves as a hash function for the NextPreviousPagerField class.

GetQueryStringNavigateUrl(Int32)

创建一个 URL,该 URL 包含具有指定页码的查询字符串字段。Creates a URL that contains a query string field that has the specified page number.

(继承自 DataPagerField)
GetType()

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

(继承自 Object)
HandleEvent(CommandEventArgs)

处理 NextPreviousPagerField 控件中发生的事件并执行适当的操作。Handles events that occur in the NextPreviousPagerField control and performs the appropriate action.

LoadViewState(Object)

还原以前保存的视图状态信息。Restores view-state information that was saved previously.

(继承自 DataPagerField)
MemberwiseClone()

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

(继承自 Object)
OnFieldChanged()

引发 FieldChanged 事件。Raises the FieldChanged event.

(继承自 DataPagerField)
SaveViewState()

保存对 DataPagerField 对象的视图状态所做的更改。Saves the changes that were made to the DataPagerField object's view state.

(继承自 DataPagerField)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
TrackViewState()

使 DataPagerField 对象跟踪其视图状态更改,以便这些更改可以存储在控件的 ViewState 属性中并在同一页的不同请求间保留。Causes the DataPagerField object to track changes to its view state so that they can be stored in the control's ViewState property and persisted across requests for the same page.

(继承自 DataPagerField)

显式接口实现

IStateManager.IsTrackingViewState

获取一个值,该值指示 DataPagerField 对象是否在跟踪其视图状态更改。Gets a value that indicates whether the DataPagerField object is tracking its view-state changes.

(继承自 DataPagerField)
IStateManager.LoadViewState(Object)

还原以前保存的视图状态信息。Restores view-state information that was saved previously.

(继承自 DataPagerField)
IStateManager.SaveViewState()

保存对 DataPagerField 对象的视图状态所做的更改。Saves the changes that were made to the DataPagerField object's view state.

(继承自 DataPagerField)
IStateManager.TrackViewState()

使 DataPagerField 对象跟踪其视图状态更改,以便这些更改可以存储在控件的 ViewState 属性中并在同一页的不同请求间保留。Causes the DataPagerField object to track changes to its view state so that they can be stored in the control's ViewState property and persisted across requests for the same page.

(继承自 DataPagerField)

适用于

另请参阅