DataPager.PagedControlID 속성

정의

ID 컨트롤에서 페이징할 데이터가 들어 있는 컨트롤의 DataPager를 가져오거나 설정합니다.

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

속성 값

String

ID 컨트롤에서 페이징할 데이터가 들어 있는 컨트롤의 DataPager입니다. 기본값은 빈 문자열로, 이 속성이 설정되지 않았음을 나타냅니다.

특성
ThemeableAttribute WebCategoryAttribute

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다는 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 제어 합니다.

이 속성이 빈 문자열인 경우 또는 nullDataPager 컨트롤이 해당 컨테이너 컨트롤을 구현할지 여부를 확인 합니다 IPageableItemContainer 인터페이스입니다. 예를 들어,를 ListView 컨트롤을 PagedControlID 속성을 추가한 경우 설정할 필요가 없습니다를 DataPager 컨트롤 내부를 ListView.LayoutTemplate 템플릿. 때문에 이것이 DataPager 컨트롤이 자동으로 찾을 수는 ListView 컨트롤 트리를 검사 하 여 제어 합니다.

이 속성의 값은 뷰 상태에 저장 됩니다.

적용 대상

추가 정보