FormView.PagerTemplate プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FormView.PagerTemplate プロパティの意味・解説 

FormView.PagerTemplate プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

FormView コントロールのページ行用のカスタム コンテンツを取得または設定します。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

<TemplateContainerAttribute(GetType(FormView))> _
Public Overridable Property
 PagerTemplate As ITemplate
Dim instance As FormView
Dim value As ITemplate

value = instance.PagerTemplate

instance.PagerTemplate = value
[TemplateContainerAttribute(typeof(FormView))] 
public virtual ITemplate PagerTemplate { get;
 set; }
[TemplateContainerAttribute(typeof(FormView))] 
public:
virtual property ITemplate^ PagerTemplate {
    ITemplate^ get ();
    void set (ITemplate^ value);
}
/** @property */
public ITemplate get_PagerTemplate ()

/** @property */
public void set_PagerTemplate (ITemplate value)
public function get PagerTemplate
 () : ITemplate

public function set PagerTemplate
 (value : ITemplate)

プロパティ値
ページ行のカスタム コンテンツを含んだ System.Web.UI.ITemplate。既定値は null で、このプロパティが設定されていないことを示します。

解説解説

ページ行は、ページング機能が有効になっている場合 (AllowPaging が true に設定されている場合) に、FormView コントロールに表示されます。ページ行には、ユーザーがコントロール内の別のページに移動できるコントロールが含まれています。組み込みのページ行ユーザー インターフェイス (UI) を使用する代わりに、PagerTemplate プロパティを設定して、独自の UI を定義できます。

メモメモ

PagerTemplate プロパティが設定されると、組み込みのページ行 UI は上書きされます。

ページ行のカスタム テンプレートを指定するには、最初に <PagerTemplate> タグを FormView コントロールの開始タグと終了タグの間に配置します。その後、<PagerTemplate> の開始タグと終了タグの間に、テンプレートの内容のリストを記述できます。ページ行の外観を制御するには、PagerStyle プロパティを使用します。

通常、ページャ テンプレートにボタン コントロールが追加してページング操作を実行します。CommandName プロパティが "Page" に設定されているボタン コントロールをクリックすると、FormView コントロールがページング操作を実行します。ボタンの CommandArgument プロパティによって、実行するページング操作の種類が決まります。FormView コントロールでサポートされるコマンド引数値の一覧を次の表に示します。

使用例使用例

カスタム ページャ テンプレートを定義する方法を次の例に示します。

<%@ Page language="VB" %>

<script runat="server">

  Sub EmployeeFormView_DataBound(ByVal sender
 As Object, ByVal e As
 EventArgs)

    ' Get the pager row.
    Dim pagerRow As FormViewRow = EmployeeFormView.BottomPagerRow

    ' Get the Label controls that display the current page information
 
    ' from the pager row.
    Dim pageNum As Label = CType(pagerRow.Cells(0).FindControl("PageNumberLabel"),
 Label)
    Dim totalNum As Label = CType(pagerRow.Cells(0).FindControl("TotalPagesLabel"),
 Label)

    If pageNum IsNot Nothing And
 totalNum IsNot Nothing Then

      ' Update the Label controls with the current page values.
      Dim page As Integer
 = EmployeeFormView.PageIndex + 1
      Dim count As Integer
 = EmployeeFormView.PageCount

      pageNum.Text = page.ToString()
      totalNum.Text = count.ToString()
    
    End If

  End Sub
    
</script>

<html>
  <body>
    <form runat="server">
        
      <h3>FormView PagerTemplate Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        ondatabound="EmployeeFormView_DataBound" 
        runat="server">
        
        <itemtemplate>
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>'
 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName")
 %>&nbsp;<%# Eval("LastName") %></h3>
      
                <%# Eval("Title") %>       
 
              </td>
            </tr>
          </table>    
        </itemtemplate>
        
        <pagertemplate>   
          <table width="100%">
            <tr>
              <td>
                <asp:linkbutton id="PreviousButton"
                  text="<"
                  commandname="Page"
                  commandargument="Prev"
                  runat="Server"/>
                <asp:linkbutton id="NextButton"
                  text=">"
                  commandname="Page"
                  commandargument="Next"
                  runat="Server"/> 
              </td>
              <td align="right">           
     
                Page <asp:label id="PageNumberLabel"
 runat="server"/> 
                of <asp:label id="TotalPagesLabel"
 runat="server"/>                
              </td>
            </tr>
          </table>          
        </pagertemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- This example uses Microsoft SQL Server and connects
  -->
      <!-- to the Northwind sample database. Use an ASP.NET
     -->
      <!-- expression to retrieve the connection string
 value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName],
 [Title], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<script runat="server">

  void EmployeeFormView_DataBound(Object sender, EventArgs e)
  {

    // Get the pager row.
    FormViewRow pagerRow = EmployeeFormView.BottomPagerRow;

    // Get the Label controls that display the current page information
 
    // from the pager row.
    Label pageNum = (Label)pagerRow.Cells[0].FindControl("PageNumberLabel");
    Label totalNum = (Label)pagerRow.Cells[0].FindControl("TotalPagesLabel");

    if ((pageNum != null) && (totalNum
 != null))
    {
      // Update the Label controls with the current page values.
      int page = EmployeeFormView.PageIndex + 1;
      int count = EmployeeFormView.PageCount;

      pageNum.Text = page.ToString();
      totalNum.Text = count.ToString();
    }    

  }
    
</script>

<html>
  <body>
    <form runat="server">
        
      <h3>FormView PagerTemplate Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        ondatabound="EmployeeFormView_DataBound" 
        runat="server">
        
        <itemtemplate>
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %>&nbsp;<%#
 Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>    
        </itemtemplate>
        
        <pagertemplate>   
          <table width="100%">
            <tr>
              <td>
                <asp:linkbutton id="PreviousButton"
                  text="<"
                  commandname="Page"
                  commandargument="Prev"
                  runat="Server"/>
                <asp:linkbutton id="NextButton"
                  text=">"
                  commandname="Page"
                  commandargument="Next"
                  runat="Server"/> 
              </td>
              <td align="right">                
                Page <asp:label id="PageNumberLabel" runat="server"/>
 
                of <asp:label id="TotalPagesLabel" runat="server"/>
                
              </td>
            </tr>
          </table>          
        </pagertemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value
   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title],
 [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormView クラス
FormView メンバ
System.Web.UI.WebControls 名前空間
System.Web.UI.ITemplate
FormView.PagerStyle プロパティ
FormView.PagerSettings プロパティ
FormView.PageCount プロパティ
FormView.PageIndex プロパティ
FormView.BottomPagerRow プロパティ
TopPagerRow
FormView.EditItemTemplate プロパティ
FormView.EmptyDataTemplate プロパティ
FormView.FooterTemplate プロパティ
FormView.HeaderTemplate プロパティ
FormView.InsertItemTemplate プロパティ
FormView.ItemTemplate プロパティ
PageIndexChanged
PageIndexChanging



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「FormView.PagerTemplate プロパティ」の関連用語

FormView.PagerTemplate プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FormView.PagerTemplate プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS