TemplatePagerField 클래스

정의

사용자 지정 페이징 UI를 만들 수 있는 DataPager 필드를 나타냅니다.

public ref class TemplatePagerField : System::Web::UI::WebControls::DataPagerField
public class TemplatePagerField : System.Web.UI.WebControls.DataPagerField
type TemplatePagerField = class
    inherit DataPagerField
Public Class TemplatePagerField
Inherits DataPagerField
상속
TemplatePagerField

예제

다음 예제에서는 추가 하는 방법을 보여 줍니다는 TemplatePagerField 필드에 DataPager 제어 합니다. 이 예제에서는 TemplatePagerField 현재 페이지 번호, 페이지의 총 수 및 총 레코드 수를 표시 합니다. 합니다 DataPager 도 컨트롤은 두 개가 포함 됩니다 NextPreviousPagerField 필드 및 NumericPagerField 사용자가 데이터 통해 페이징할 수 있는 탐색 컨트롤에 표시할 필드입니다.

<%@ 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>TemplatePagerField Example</title>    
    <style type="text/css">
      body 	
      {
        text-align: center;
        font: 12px Arial, Helvetica, sans-serif;
      }
      .item
      {
        border: solid 1px #458b74;
        background: #e0ffff;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>TemplatePagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table runat="server" id="tblContacts" width="350">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
         </LayoutTemplate>
         <ItemTemplate>
            <tr runat="server">
              <td class="item">
                <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
              </td>            
              <td align="left" class="item">
                <asp:Label ID="NameLabel" runat="server" 
                  Text='<%#Eval("LastName") + ", " + Eval("FirstName")%>' />
              </td>
            </tr>
          </ItemTemplate>
      </asp:ListView>
      <br />

      <asp:DataPager runat="server" 
        ID="ContactsDataPager" 
        PageSize="20"          
        PagedControlID="ContactsListView">
        <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) %>" />
            (
            <asp:Label runat="server" ID="TotalItemsLabel" 
              Text="<%# Container.TotalRowCount%>" />
            records)
            <br />
            </b>
            </PagerTemplate>
          </asp:TemplatePagerField>
          
          <asp:NextPreviousPagerField
            ButtonType="Button"
            ShowFirstPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false" />
          
          <asp:NumericPagerField 
            PreviousPageText="< Prev 10"
            NextPageText="Next 10 >"
            ButtonCount="10" />
            
          <asp:NextPreviousPagerField
            ButtonType="Button"
            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 [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>TemplatePagerField Example</title>    
    <style type="text/css">
      body 	
      {
        text-align: center;
        font: 12px Arial, Helvetica, sans-serif;
      }
      .item
      {
        border: solid 1px #458b74;
        background: #e0ffff;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>TemplatePagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table runat="server" id="tblContacts" width="350">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
         </LayoutTemplate>
         <ItemTemplate>
            <tr runat="server">
              <td class="item">
                <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
              </td>            
              <td align="left" class="item">
                <asp:Label ID="NameLabel" runat="server" 
                  Text='<%#Eval("LastName") & ", " & Eval("FirstName")%>' />
              </td>
            </tr>
          </ItemTemplate>
      </asp:ListView>
      <br />

      <asp:DataPager runat="server" 
        ID="ContactsDataPager" 
        PageSize="20"          
        PagedControlID="ContactsListView">
        <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) %>" />
            (
            <asp:Label runat="server" ID="TotalItemsLabel" 
              Text="<%# Container.TotalRowCount%>" />
            records)
            <br />
            </b>
            </PagerTemplate>
          </asp:TemplatePagerField>
          
          <asp:NextPreviousPagerField
            ButtonType="Button"
            ShowFirstPageButton="true"
            ShowNextPageButton="false"
            ShowPreviousPageButton="false" />
          
          <asp:NumericPagerField 
            PreviousPageText="< Prev 10"
            NextPageText="Next 10 >"
            ButtonCount="10" />
            
          <asp:NextPreviousPagerField
            ButtonType="Button"
            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 [ContactID], [FirstName], [LastName] 
          FROM Person.Contact">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

다음 예제에서는 사용 하는 방법을 보여 줍니다 합니다 PagerCommand 단추가 클릭 되었음을 따라 다른 작업을 수행 하는 이벤트를 TemplatePagerField 필드입니다. 이 예제에서는 TemplatePagerField 사용자가 데이터 통해 페이징할 수 있는 탐색 컨트롤을 표시 합니다.

<%@ Page language="C#" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<script runat="server">

  // <Snippet2>  
  protected void TemplatePagerField_OnPagerCommand(object sender, DataPagerCommandEventArgs e)
  { 
    // Check which button raised the event
    switch(e.CommandName)
    {
      case "Next":
        int newIndex = e.Item.Pager.StartRowIndex + e.Item.Pager.PageSize;
        if (newIndex <= e.TotalRowCount)
        {
          e.NewStartRowIndex = newIndex;
          e.NewMaximumRows = e.Item.Pager.MaximumRows;
        }
        break;
      case "Previous":
        e.NewStartRowIndex = e.Item.Pager.StartRowIndex - e.Item.Pager.PageSize;
        e.NewMaximumRows = e.Item.Pager.MaximumRows;
        break;
      case "First":
        e.NewStartRowIndex = 0;
        e.NewMaximumRows = e.Item.Pager.MaximumRows;
        break;
    }
  }
  // </Snippet2>
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>TemplatePagerField.OnPagerCommand Example</title>    
    <style type="text/css">
      body 	
      {
        text-align: center;
        font: 12px Arial, Helvetica, sans-serif;
      }
      .item
      {
        border: solid 1px #2F4F4F;
        background: #E6E6FA;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>TemplatePagerField.OnPagerCommand Example</h3>
          
      <asp:ListView ID="StoresListView" 
        DataSourceID="StoresDataSource"
        runat="server">
        <LayoutTemplate>
          <table width="350" runat="server" id="tblStore">
            <tr runat="server">
              <th runat="server">ID</th>
              <th runat="server">Store Name</th>
            </tr>
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
         </LayoutTemplate>
         <ItemTemplate>
          <tr runat="server">
            <td class="item">
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("CustomerID") %>' />
            </td>            
            <td align="left" class="item">
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name")%>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>
      <br />
      
      <asp:DataPager runat="server" 
        ID="ContactsDataPager" 
        PageSize="30"
        PagedControlID="StoresListView">
        <Fields>
          <asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand">
            <PagerTemplate> 
              <asp:LinkButton ID="FirstButton" runat="server" CommandName="First" 
                Text="<<" Enabled='<%# Container.StartRowIndex > 0 %>' />
              <asp:LinkButton ID="PreviousButton" runat="server" CommandName="Previous" 
                Text='<%# (Container.StartRowIndex - Container.PageSize + 1) + " - " + (Container.StartRowIndex) %>'
                Visible='<%# Container.StartRowIndex > 0 %>' />
              <asp:Label ID="CurrentPageLabel" runat="server"
                Text='<%# (Container.StartRowIndex + 1) + "-" + (Container.StartRowIndex + Container.PageSize > Container.TotalRowCount ? Container.TotalRowCount : Container.StartRowIndex + Container.PageSize) %>' />
              <asp:LinkButton ID="NextButton" runat="server" CommandName="Next"
                Text='<%# (Container.StartRowIndex + Container.PageSize + 1) + " - " + (Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount ? Container.TotalRowCount : Container.StartRowIndex + Container.PageSize*2) %>' 
                Visible='<%# (Container.StartRowIndex + Container.PageSize) < Container.TotalRowCount %>' />
            </PagerTemplate>
          </asp:TemplatePagerField>
        </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="StoresDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
            SelectCommand="SELECT [CustomerID], [Name] FROM Sales.Store ORDER BY [Name]">
      </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">
    
<script runat="server">

  ' <Snippet2>  
  Protected Sub TemplatePagerField_OnPagerCommand(ByVal sender As Object, _
    ByVal e As DataPagerCommandEventArgs)
    
    ' Check which button raised the event
    Select Case e.CommandName
      
      Case "Next"
        Dim newIndex As Integer = e.Item.Pager.StartRowIndex + e.Item.Pager.PageSize
        If newIndex <= e.TotalRowCount Then
          e.NewStartRowIndex = newIndex
          e.NewMaximumRows = e.Item.Pager.MaximumRows
        End If
        
      Case "Previous"
        e.NewStartRowIndex = e.Item.Pager.StartRowIndex - e.Item.Pager.PageSize
        e.NewMaximumRows = e.Item.Pager.MaximumRows
        
      Case "First"
        e.NewStartRowIndex = 0
        e.NewMaximumRows = e.Item.Pager.MaximumRows
        
    End Select
  
  End Sub
  ' </Snippet2>
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>TemplatePagerField.OnPagerCommand Example</title>    
    <style type="text/css">
      body 	
      {
        text-align: center;
        font: 12px Arial, Helvetica, sans-serif;
      }
      .item
      {
        border: solid 1px #2F4F4F;
        background: #E6E6FA;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>TemplatePagerField.OnPagerCommand Example</h3>
          
      <asp:ListView ID="StoresListView" 
        DataSourceID="StoresDataSource"
        runat="server">
        <LayoutTemplate>
          <table width="350" runat="server" id="tblStore">
            <tr runat="server">
              <th runat="server">ID</th>
              <th runat="server">Store Name</th>
            </tr>
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
         </LayoutTemplate>
         <ItemTemplate>
          <tr runat="server">
            <td class="item">
              <asp:Label ID="IDLabel" runat="server" Text='<%#Eval("CustomerID") %>' />
            </td>            
            <td align="left" class="item">
              <asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name")%>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>
      <br />
      
      <asp:DataPager runat="server" 
        ID="ContactsDataPager" 
        PageSize="30"
        PagedControlID="StoresListView">
        <Fields>
          <asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand">
            <PagerTemplate> 
              <asp:LinkButton ID="FirstButton" runat="server" CommandName="First" 
                Text="<<" Enabled='<%# Container.StartRowIndex > 0 %>' />
              <asp:LinkButton ID="PreviousButton" runat="server" CommandName="Previous" 
                Text='<%# (Container.StartRowIndex - Container.PageSize + 1) & " - " & (Container.StartRowIndex) %>'
                Visible='<%# Container.StartRowIndex > 0 %>' />
              <asp:Label ID="CurrentPageLabel" runat="server"
                Text='<%# (Container.StartRowIndex + 1) & "-" & (IIf(Container.StartRowIndex + Container.PageSize > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize)) %>' />
              <asp:LinkButton ID="NextButton" runat="server" CommandName="Next"
                Text='<%# (Container.StartRowIndex + Container.PageSize + 1) & " - " & (IIf(Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount, Container.TotalRowCount, Container.StartRowIndex + Container.PageSize*2)) %>' 
                Visible='<%# (Container.StartRowIndex + Container.PageSize) < Container.TotalRowCount %>' />
            </PagerTemplate>
          </asp:TemplatePagerField>
        </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="StoresDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
            SelectCommand="SELECT [CustomerID], [Name] FROM Sales.Store ORDER BY [Name]">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

설명

사용 된 TemplatePagerField 구현 하는 컨트롤에 표시 되는 데이터를 페이징 하는 데 사용할 수 있는 탐색 컨트롤을 표시 하는 개체를 IPageableItemContainer 인터페이스입니다. (예로 ListView 제어 합니다.) 사용할 수도 있습니다는 TemplatePagerField 레코드의 총 수 및 현재 페이지 번호와 같은 기본 데이터 원본에 대 한 정보를 표시 하는 개체입니다.

TemplatePagerField 필드에 기본 제공 레이아웃이 없습니다. 따라서 명시적으로 만들어야에서 레이아웃을 PagerTemplate 템플릿. 연계 스타일 시트 (CSS) 클래스 또는 인라인 스타일 요소를 사용 하 여 콘텐츠를 포맷할 수 있습니다.

참조할 수 있습니다는 DataPager 포함 된 컨트롤을 TemplatePagerField 사용 하 여 개체를 Container 속성. 검색 된 레코드 수를 표시 하려면 바인딩 식, 총 페이지 및 유사한 정보를 만들려는 경우에 유용 합니다. 이러한 바인딩 식의 속성을 사용할 수는 DataPager 와 같은 제어 MaximumRows, PageSize, StartRowIndex, 및 TotalRowCount합니다.

TemplatePagerField 필드를 제공 합니다 PagerCommand 때 단추에 작업을 수행 하는 데 일반적으로 사용 되는 이벤트를 PagerTemplate 서식 파일을 클릭할 합니다.

생성자

TemplatePagerField()

TemplatePagerField 클래스의 새 인스턴스를 초기화합니다.

속성

DataPager

DataPagerField 개체가 연결된 데이터 페이저에 대한 참조를 가져옵니다.

(다음에서 상속됨 DataPagerField)
IsTrackingViewState

DataPagerField 개체에서 해당 뷰 상태의 변경 내용을 추적하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 DataPagerField)
PagerTemplate

DataPager 컨트롤의 페이저 필드에 대한 사용자 지정 콘텐츠를 가져오거나 설정합니다.

QueryStringHandled

쿼리 문자열 필드가 평가되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 DataPagerField)
QueryStringValue

요청 URL에서 쿼리 문자열 필드의 값을 가져옵니다.

(다음에서 상속됨 DataPagerField)
ViewState

같은 페이지에 대한 여러 요청 사이에서 DataPagerField 개체의 뷰 상태를 저장하고 복원할 수 있도록 하는 상태 정보 사전을 가져옵니다.

(다음에서 상속됨 DataPagerField)
Visible

데이터 페이저 필드가 렌더링되는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 DataPagerField)

메서드

CloneField()

DataPagerField에서 파생된 현재 개체의 복사본을 만듭니다.

(다음에서 상속됨 DataPagerField)
CopyProperties(DataPagerField)

현재 TemplatePagerField 개체의 속성을 지정된 DataPagerField 개체로 복사합니다.

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

페이저 필드 개체에 대해 UI(사용자 인터페이스) 컨트롤을 만들어 지정된 컨테이너에 추가합니다.

CreateField()

TemplatePagerField 클래스의 새 인스턴스를 만들어 반환합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetQueryStringNavigateUrl(Int32)

지정된 페이지 번호가 있는 쿼리 문자열 필드가 포함된 URL을 만듭니다.

(다음에서 상속됨 DataPagerField)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
HandleEvent(CommandEventArgs)

TemplatePagerField 개체에서 발생하는 이벤트를 처리하고 적절한 작업을 수행합니다.

LoadViewState(Object)

이전에 저장된 뷰 상태 정보를 복원합니다.

(다음에서 상속됨 DataPagerField)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnFieldChanged()

FieldChanged 이벤트를 발생시킵니다.

(다음에서 상속됨 DataPagerField)
OnPagerCommand(DataPagerCommandEventArgs)

PagerCommand 이벤트를 발생시킵니다.

SaveViewState()

DataPagerField 개체의 뷰 상태 변경 내용을 저장합니다.

(다음에서 상속됨 DataPagerField)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
TrackViewState()

DataPagerField 개체가 뷰 상태의 변경 내용을 추적하도록 합니다. 이렇게 하면 해당 뷰 상태의 변경 내용을 컨트롤의 ViewState 속성에 저장하여 같은 페이지에 대한 여러 요청에서 일관성 있게 유지할 수 있습니다.

(다음에서 상속됨 DataPagerField)

이벤트

PagerCommand

TemplatePagerField 개체에서 단추를 클릭하면 발생합니다.

명시적 인터페이스 구현

IStateManager.IsTrackingViewState

DataPagerField 개체에서 해당 뷰 상태의 변경 내용을 추적하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 DataPagerField)
IStateManager.LoadViewState(Object)

이전에 저장된 뷰 상태 정보를 복원합니다.

(다음에서 상속됨 DataPagerField)
IStateManager.SaveViewState()

DataPagerField 개체의 뷰 상태 변경 내용을 저장합니다.

(다음에서 상속됨 DataPagerField)
IStateManager.TrackViewState()

DataPagerField 개체가 뷰 상태의 변경 내용을 추적하도록 합니다. 이렇게 하면 해당 뷰 상태의 변경 내용을 컨트롤의 ViewState 속성에 저장하여 같은 페이지에 대한 여러 요청에서 일관성 있게 유지할 수 있습니다.

(다음에서 상속됨 DataPagerField)

적용 대상

추가 정보