DataPagerField クラス

定義

DataPager コントロールのナビゲーション コントロールを表すデータ ページャー フィールド型の基底クラスとして機能します。

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
継承
DataPagerField
派生
実装

次の例では、および TemplatePagerField オブジェクトを使用NextPreviousPagerFieldNumericPagerFieldして、コントロール内のページ ナビゲーション コントロールを表示する方法をDataPager示します。 オブジェクトは、 クラスから DataPagerField 派生します。

<%@ 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> </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="<<"
            NextPageText=">>"
            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> </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="<<"
            NextPageText=">>"
            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 、すべてのデータ ページャー フィールド型の基底クラスとして機能します。 データ ページャー フィールドは、ナビゲーション コントロールを DataPager 表すためにコントロールによって使用されます。

から DataPagerField 派生したクラスを使用して、コントロールに表示されるポケットベルの種類を DataPager 選択します。 次の表に、使用可能なデータ ページャー フィールドの種類を示します。

Pager フィールドの種類 [説明]
NextPreviousPagerField ユーザーが一度に 1 ページずつデータ ページ間を移動したり、最初または最後のページにジャンプしたりできます。
NumericPagerField ユーザーがページ番号でページを選択できるようにします。
TemplatePagerField ページ開発者がカスタム ページング UI を作成できるようにします。

クラスから派生して、追加の DataPagerField ポケットベル フィールド型を作成できます。

注意 (実装者)

クラスから継承する場合は、次の DataPagerField メンバーをオーバーライドする必要があります。

コンストラクター

DataPagerField()

DataPagerField クラスの新しいインスタンスを初期化します。

プロパティ

DataPager

DataPagerField オブジェクトが関連付けられているデータ ページャーへの参照を取得します。

IsTrackingViewState

DataPagerField オブジェクトでビューステートの変化を追跡しているかどうかを示す値を取得します。

QueryStringHandled

クエリ文字列フィールドが評価されたかどうかを示す値を取得または設定します。

QueryStringValue

要求の URL からクエリ文字列フィールドの値を取得します。

ViewState

同一のページに対する複数の要求にわたって、DataPagerField オブジェクトのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。

Visible

データ ページャー フィールドを表示するかどうかを示す値を取得または設定します。

メソッド

CloneField()

DataPagerField から派生した現在のオブジェクトのコピーを作成します。

CopyProperties(DataPagerField)

DataPagerField から派生した現在のオブジェクトのプロパティを、指定した DataPagerField オブジェクトにコピーします。

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

派生クラスでオーバーライドされた場合、データ ページャー フィールド オブジェクトのユーザー インターフェイス (UI) コントロールを作成し、指定のコンテナーに追加します。

CreateField()

派生クラスでオーバーライドされた場合、DataPagerField から派生した空のオブジェクトを作成します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetQueryStringNavigateUrl(Int32)

指定のページ番号を持つクエリ文字列フィールドが含まれる URL を作成します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
HandleEvent(CommandEventArgs)

派生クラスでオーバーライドされた場合、データ ページャー フィールド オブジェクトで発生するイベントを処理します。

LoadViewState(Object)

以前に保存したビューステート情報を復元します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnFieldChanged()

FieldChanged イベントを発生させます。

SaveViewState()

DataPagerField オブジェクトのビューステートに加えられた変更を保存します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
TrackViewState()

DataPagerField オブジェクトがそのビューステートの変更を追跡するようにします。これにより、変更をコントロールの ViewState プロパティに格納し、同じページに対する複数の要求の間で保持できるようになります。

明示的なインターフェイスの実装

IStateManager.IsTrackingViewState

DataPagerField オブジェクトでビューステートの変化を追跡しているかどうかを示す値を取得します。

IStateManager.LoadViewState(Object)

以前に保存したビューステート情報を復元します。

IStateManager.SaveViewState()

DataPagerField オブジェクトのビューステートに加えられた変更を保存します。

IStateManager.TrackViewState()

DataPagerField オブジェクトがそのビューステートの変更を追跡するようにします。これにより、変更をコントロールの ViewState プロパティに格納し、同じページに対する複数の要求の間で保持できるようになります。

適用対象

こちらもご覧ください