DataPager.PagedControlID プロパティ

定義

ID コントロールによってページングされるデータを含むコントロールの DataPager を取得または設定します。

public:
 virtual property System::String ^ PagedControlID { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.Themeable(false)]
public virtual string PagedControlID { get; set; }
[<System.Web.UI.Themeable(false)>]
member this.PagedControlID : string with get, set
Public Overridable Property PagedControlID As String

プロパティ値

ID コントロールによってページングされるデータを含むコントロールの DataPager。 既定値は空の文字列です。このプロパティが設定されていないことを示します。

属性

次の例では、 プロパティを使用してコントロールを PagedControlID コントロールに動的に関連付ける ListView 方法を DataPager 示します。 このコード例は、コンストラクターに対して提供されるより大きな例の DataPager 一部です。

protected void Page_Load(object sender, EventArgs e)
{

  // Create a new DataPager object.
  DataPager CountryDataPager = new DataPager();

  // Set the DataPager object's properties.
  CountryDataPager.PagedControlID = CountryListView.ID;
  CountryDataPager.PageSize = 15;
  CountryDataPager.Fields.Add(new NumericPagerField());

  // Add the DataPager object to the Controls collection
  // of the form.
  form1.Controls.Add(CountryDataPager);

  CountryListView.DataBind();
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  
  ' Create a new DataPager object.
  Dim CountryDataPager As New DataPager()
      
  ' Set the DataPager object's properties.
  CountryDataPager.PagedControlID = CountryListView.ID
  CountryDataPager.PageSize = 15
  CountryDataPager.Fields.Add(New NumericPagerField())
      
  ' Add the DataPager object to the Controls collection
  ' of the form.
  form1.Controls.Add(CountryDataPager)

  CountryListView.DataBind()
  
End Sub

次の例では、コントロールのデータを PagedControlID ページングするために、コントロールの プロパティを DataPager 宣言的に設定する方法を ListView 示します。

<%@ 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>DataPager PagedControlID Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>DataPager PagedControlID Example</h3>
      
      <asp:DataPager ID="DepartmentsPager" runat="server" 
        PagedControlID="DepartmentsListView">
        <Fields>
          <asp:NumericPagerField />
        </Fields>
      </asp:DataPager>
      
      <asp:ListView ID="DepartmentsListView" 
        DataSourceID="DepartmentsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="500px">
            <tr>
              <th>Department Name</th>
              <th>Group</th>
            </tr>
            <tr runat="server" id="itemPlaceholder"></tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
            </td>
            <td>
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%# Eval("GroupName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <!-- 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="DepartmentsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"            
        SelectCommand="SELECT Name, GroupName FROM HumanResources.Department" >
      </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>DataPager PagedControlID Example</title>
</head>
<body>
    <form id="form1" runat="server">
      
      <h3>DataPager PagedControlID Example</h3>
      
      <asp:DataPager ID="DepartmentsPager" runat="server" 
        PagedControlID="DepartmentsListView">
        <Fields>
          <asp:NumericPagerField />
        </Fields>
      </asp:DataPager>
      
      <asp:ListView ID="DepartmentsListView" 
        DataSourceID="DepartmentsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="500px">
            <tr>
              <th>Department Name</th>
              <th>Group</th>
            </tr>
            <tr runat="server" id="itemPlaceholder"></tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
            </td>
            <td>
              <asp:Label ID="GroupNameLabel" runat="server" Text='<%# Eval("GroupName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <!-- 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="DepartmentsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"            
        SelectCommand="SELECT Name, GroupName FROM HumanResources.Department" >
      </asp:SqlDataSource>
    </form>
  </body>
</html>

注釈

プロパティを PagedControlID 使用して、 ID コントロールによってページングされるデータを含むコントロールの を DataPager 指定します。 指定したコントロールは インターフェイスを IPageableItemContainer 実装し、コントロールと同じ名前付けコンテナーを使用する DataPager 必要があります。 指定できるコントロールの例として、 コントロールがあります ListView

このプロパティが空の文字列または nullの場合、コントロールは DataPager コンテナー コントロールが インターフェイスを IPageableItemContainer 実装しているかどうかを確認します。 たとえば、 コントロールではListView、テンプレート内にPagedControlIDコントロールを配置する場合、プロパティを設定するDataPagerListView.LayoutTemplate必要はありません。 これは、コントロールツリーを DataPager 調べることでコントロールを ListView 自動的に見つけることができるためです。

このプロパティの値はビューステートに格納されます。

適用対象

こちらもご覧ください