DataPagerField DataPagerField DataPagerField DataPagerField Class

定義

作為資料頁面巡覽區欄位類型的基底類別,代表 DataPager 控制項的導覽控制項。Serves as the base class for data pager field types, which represent a navigation control for the DataPager control.

public ref class DataPagerField abstract : System::Web::UI::IStateManager
public abstract class DataPagerField : System.Web.UI.IStateManager
type DataPagerField = class
    interface IStateManager
Public MustInherit Class DataPagerField
Implements IStateManager
繼承
DataPagerFieldDataPagerFieldDataPagerFieldDataPagerField
衍生
實作

範例

下列範例NextPreviousPagerField示範如何使用、和NumericPagerField TemplatePagerField DataPager物件, 在控制項中顯示頁面導覽控制項。The following example shows how to use NextPreviousPagerField, NumericPagerField, and TemplatePagerField objects to display page navigation controls in a DataPager control. 物件衍生自DataPagerField類別。The objects are derived from the DataPagerField class.

<%@ 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>DataPagerField Example</title>    
    <style type="text/css">
      body  
      {
        text-align: center; 
        font: 13px Tahoma, Arial, Helvetica;
      }
      .item
      {
        border-bottom: solid 1px #FFA500;
        font-weight:bold;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>DataPagerField Example</h3>
          
      <asp:ListView ID="ProductsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table runat="server" id="tblProducts" width="350">
            <tr runat="server" id="itemPlaceholder" />
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td class="item">
              <asp:Label ID="NameLabel" runat="server" 
                Text='<%#Eval("Name") %>' />
            </td>
          </tr>
          <tr runat="server">
            <td>
              <asp:Label ID="DescriptionLabel" runat="server" 
                Text='<%#Eval("Description")%>' />
            </td>
          </tr>
        </ItemTemplate>
        <ItemSeparatorTemplate>
          <tr runat="server">
            <td>&nbsp;</td>
          </tr>
        </ItemSeparatorTemplate>
      </asp:ListView>
      <br />

      <asp:DataPager runat="server" 
        ID="ProductsDataPager" 
        PageSize="5"
        PagedControlID="ProductsListView">
        <Fields>
          <asp:TemplatePagerField>
            <PagerTemplate>
            <b>
            Page
            <asp:Label runat="server" ID="CurrentPageLabel" 
              Text="<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>" />
            of
            <asp:Label runat="server" ID="TotalPagesLabel" 
              Text="<%# Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize) %>" />
            </b>
            <br /><br />
            </PagerTemplate>
          </asp:TemplatePagerField>
          
          <asp:NextPreviousPagerField
            ShowFirstPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false" />
          
          <asp:NumericPagerField 
            PreviousPageText="&lt;&lt;"
            NextPageText="&gt;&gt;"
            ButtonCount="10" />
            
          <asp:NextPreviousPagerField
            ShowLastPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false" />
        </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 P.Name, PD.Description 
                      FROM Production.ProductModel AS PM 
                      INNER JOIN Production.Product AS P ON PM.ProductModelID = P.ProductModelID 
                      INNER JOIN Production.ProductModelProductDescriptionCulture AS PMPDC 
                      ON PM.ProductModelID = PMPDC.ProductModelID 
                      INNER JOIN Production.ProductDescription AS PD 
                      ON PMPDC.ProductDescriptionID = PD.ProductDescriptionID 
                      WHERE (PMPDC.CultureID = 'en')">
      </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>DataPagerField Example</title>    
    <style type="text/css">
      body  
      {
        text-align: center; 
        font: 13px Tahoma, Arial, Helvetica;
      }
      .item
      {
        border-bottom: solid 1px #FFA500;
        font-weight:bold;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>DataPagerField Example</h3>
          
      <asp:ListView ID="ProductsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table runat="server" id="tblProducts" width="350">
            <tr runat="server" id="itemPlaceholder" />
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td class="item">
              <asp:Label ID="NameLabel" runat="server" 
                Text='<%#Eval("Name") %>' />
            </td>
          </tr>
          <tr runat="server">
            <td>
              <asp:Label ID="DescriptionLabel" runat="server" 
                Text='<%#Eval("Description")%>' />
            </td>
          </tr>
        </ItemTemplate>
        <ItemSeparatorTemplate>
          <tr runat="server">
            <td>&nbsp;</td>
          </tr>
        </ItemSeparatorTemplate>
      </asp:ListView>
      <br />

      <asp:DataPager runat="server" 
        ID="ProductsDataPager" 
        PageSize="5"
        PagedControlID="ProductsListView">
        <Fields>
          <asp:TemplatePagerField>
            <PagerTemplate>
            <b>
            Page
            <asp:Label runat="server" ID="CurrentPageLabel" 
              Text="<%# IIf(Container.TotalRowCount>0, (Container.StartRowIndex / Container.PageSize) + 1, 0) %>" />
            of
            <asp:Label runat="server" ID="TotalPagesLabel" 
              Text="<%# Math.Ceiling (System.Convert.ToDouble(Container.TotalRowCount) / Container.PageSize) %>" />
            </b>
            <br /><br />            
            </PagerTemplate>
          </asp:TemplatePagerField>
          
          <asp:NextPreviousPagerField
            ShowFirstPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false" />
          
          <asp:NumericPagerField 
            PreviousPageText="&lt;&lt;"
            NextPageText="&gt;&gt;"
            ButtonCount="10" />
            
          <asp:NextPreviousPagerField
            ShowLastPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false" />
        </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 P.Name, PD.Description 
                      FROM Production.ProductModel AS PM 
                      INNER JOIN Production.Product AS P ON PM.ProductModelID = P.ProductModelID 
                      INNER JOIN Production.ProductModelProductDescriptionCulture AS PMPDC 
                      ON PM.ProductModelID = PMPDC.ProductModelID 
                      INNER JOIN Production.ProductDescription AS PD 
                      ON PMPDC.ProductDescriptionID = PD.ProductDescriptionID 
                      WHERE (PMPDC.CultureID = 'en')">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

備註

DataPagerField類別可做為所有資料頁呼機欄位類型的基類。The DataPagerField class serves as the base class for all data pager field types. DataPager控制項會使用資料頁呼機欄位來代表導覽控制項。Data pager fields are used by the DataPager control to represent a navigation control.

使用衍生自DataPagerField的類別, 以選取要DataPager在控制項中顯示的分頁類型。Use the classes that are derived from DataPagerField to select which type of pager is displayed in the DataPager control. 下表列出可用的資料頁呼機欄位類型。The following table lists available data pager field types.

呼機欄位類型Pager field type 說明Description
NextPreviousPagerField 可讓使用者一次流覽一頁的資料頁, 或跳到第一個或最後一頁。Lets users navigate through data pages one page at a time, or to jump to the first or last page.
NumericPagerField 讓使用者依頁碼選取頁面。Lets users select a page by page number.
TemplatePagerField 讓網頁開發人員建立自訂分頁 UI。Lets page developers create a custom paging UI.

您可以衍生自DataPagerField類別, 以建立其他的分頁程式欄位類型。You can derive from the DataPagerField class to create additional pager field types.

給繼承者的注意事項

當您繼承自DataPagerField類別時, 必須覆寫下列成員:When you inherit from the DataPagerField class, you must override the following members:

建構函式

DataPagerField() DataPagerField() DataPagerField() DataPagerField()

初始化 DataPagerField 類別的新執行個體。Initializes a new instance of the DataPagerField class.

屬性

DataPager DataPager DataPager DataPager

取得與 DataPagerField 物件關聯之資料頁面巡覽區的參考。Gets a reference to the data pager that the DataPagerField object is associated with.

IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

取得值,這個值表示 DataPagerField 物件是否正在追蹤它的檢視狀態變更。Gets a value that indicates whether the DataPagerField object is tracking its view-state changes.

QueryStringHandled QueryStringHandled QueryStringHandled QueryStringHandled

取得或設定值,這個值表示是否已評估查詢字串欄位。Gets or sets a value that indicates whether the query string field has been evaluated.

QueryStringValue QueryStringValue QueryStringValue QueryStringValue

從要求的 URL 取得查詢字串欄位的值。Gets the value of the query string field from the URL of the request.

ViewState ViewState ViewState 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.

Visible Visible Visible Visible

取得或設定值,這個值表示是否呈現資料頁面巡覽區欄位。Gets or sets a value that indicates whether a data pager field is rendered.

方法

CloneField() CloneField() CloneField() CloneField()

建立衍生自 DataPagerField 之目前物件的複本。Creates a copy of the current object that is derived from DataPagerField.

CopyProperties(DataPagerField) CopyProperties(DataPagerField) CopyProperties(DataPagerField) CopyProperties(DataPagerField)

將衍生自 DataPagerField 之目前物件的屬性複製至指定的 DataPagerField 物件。Copies the properties of the current object derived from DataPagerField to the specified DataPagerField object.

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

在衍生類別中遭覆寫時,建立資料頁面巡覽區欄位物件的使用者介面 (UI) 控制項,並將它們加入至指定的容器。When overridden in a derived class, creates the user interface (UI) controls for the data pager field object and adds them to the specified container.

CreateField() CreateField() CreateField() CreateField()

在衍生類別中遭覆寫時,建立實際上是衍生 DataPagerField 的空物件。When overridden in a derived class, creates an empty object that is derived DataPagerField.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetQueryStringNavigateUrl(Int32) GetQueryStringNavigateUrl(Int32) GetQueryStringNavigateUrl(Int32) GetQueryStringNavigateUrl(Int32)

建立 URL,這個 URL 包含含有所指定頁碼的查詢字串欄位。Creates a URL that contains a query string field that has the specified page number.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
HandleEvent(CommandEventArgs) HandleEvent(CommandEventArgs) HandleEvent(CommandEventArgs) HandleEvent(CommandEventArgs)

在衍生類別中遭覆寫時,處理資料頁面巡覽區欄位物件中發生的事件。When overridden in a derived class, handles events that occur in the data pager field object.

LoadViewState(Object) LoadViewState(Object) LoadViewState(Object) LoadViewState(Object)

還原先前儲存的檢視狀態資訊。Restores view-state information that was saved previously.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
OnFieldChanged() OnFieldChanged() OnFieldChanged() OnFieldChanged()

引發 FieldChanged 事件。Raises the FieldChanged event.

SaveViewState() SaveViewState() SaveViewState() SaveViewState()

儲存 DataPagerField 物件的檢視狀態變更。Saves the changes that were made to the DataPagerField object's view state.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
TrackViewState() TrackViewState() TrackViewState() 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.

明確介面實作

IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState

取得值,這個值表示 DataPagerField 物件是否正在追蹤它的檢視狀態變更。Gets a value that indicates whether the DataPagerField object is tracking its view-state changes.

IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object)

還原先前儲存的檢視狀態資訊。Restores view-state information that was saved previously.

IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState()

儲存 DataPagerField 物件的檢視狀態變更。Saves the changes that were made to the DataPagerField object's view state.

IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState() 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.

適用於

另請參閱