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物件來逐頁查看ListView控制項中顯示的資料。The 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>

備註

類別代表在DataPager控制項中顯示導覽控制項的欄位。 NextPreviousPagerFieldThe NextPreviousPagerField class represents a field that displays navigation controls in a DataPager control. 這些導覽控制項可以用來逐頁查看執行IPageableItemContainer介面之控制項 (例如ListView控制項) 所顯示的資料。These 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 ButtonCssClass使用屬性來設定按鈕的樣式, 以自訂物件的外觀。You 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.

您可以藉由NextPreviousPagerFieldVisible屬性設定DataPagerfalse, 隱藏控制項中的物件。You can hide a NextPreviousPagerField object in a DataPager control by setting the Visible property to false. 您也ShowFirstPageButton可以將、、 ShowNextPageButtonShowLastPageButton屬性設定為, ShowPreviousPageButtonfalse隱藏個別按鈕 (第一頁、上一頁、下一頁和最後一頁的按鈕)。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.

FirstPageText PreviousPageText NextPageText控制項可讓您使用、、和LastPageText屬性, 指定每個按鈕的自訂文字。 NextPreviousPagerFieldThe NextPreviousPagerField control enables you to specify custom text for each button by using the FirstPageText, PreviousPageText, NextPageText, and LastPageText properties.

當屬性設定為ButtonType.Image時, 您必須提供要為按鈕顯示之影像的 URL。 ButtonTypeWhen the ButtonType property is set to ButtonType.Image, you must provide the URL to an image that will be displayed for the button. 您可以藉FirstPageImageUrl由設定、、 NextPageImageUrlLastPageImageUrl屬性, PreviousPageImageUrl為每個按鈕個別設定影像。You can set images individually for each button by setting the FirstPageImageUrl, PreviousPageImageUrl, NextPageImageUrl, and LastPageImageUrl properties.

當屬性設定為ButtonType.Image時, 對應的 text 屬性會作為影像的替代文字。 ButtonTypeWhen 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 的淺層複本 (Shallow Copy)。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)

適用於

另請參閱