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

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

GridView.TopPagerRow プロパティ

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

GridView コントロールの上部のページ行を表す GridViewRow オブジェクト取得します

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

Public Overridable ReadOnly
 Property TopPagerRow As GridViewRow
Dim instance As GridView
Dim value As GridViewRow

value = instance.TopPagerRow
public virtual GridViewRow TopPagerRow { get;
 }
public:
virtual property GridViewRow^ TopPagerRow {
    GridViewRow^ get ();
}
/** @property */
public GridViewRow get_TopPagerRow ()
public function get TopPagerRow
 () : GridViewRow

プロパティ
コントロールの上部のページ行を表す GridViewRow

解説解説

(AllowPaging プロパティtrue設定することによって) ページング有効になっている場合ページ行と呼ばれる追加行が自動的に GridView コントロール表示されます。ページ行には、ユーザーが他のページ移動できるようにするコントロール含まれコントロールの上部、下部、または上部下部両方表示できますプログラムによって GridView コントロールの上部のページ行を表す GridViewRow オブジェクトアクセスするには、TopPagerRow プロパティ使用します

メモメモ

TopPagerRow プロパティは、RowCreated イベントGridView によって上部ページ行が作成された後にしか使用できません。

通常、このプロパティは、プログラムによって上部ページ行を操作する必要がある場合 (カスタム コンテンツ追加する場合など) に使用されます。TopPagerRow プロパティへの変更は、GridView コントロール表示した後に行う必要がありますそうしないと、GridView コントロールによって変更上書きされます

使用例使用例

TopPagerRow プロパティ使用してGridView コントロールの上部のページ行にアクセスする方法次のコード例示しますTopPagerRow プロパティ使用してページ行から DropDownList コントロール取得されます。

<%@ Page language="VB" %>

<script runat="server">

  Sub PageDropDownList_SelectedIndexChanged(ByVal
 sender As Object, ByVal
 e As EventArgs)
    
    ' Retrieve the pager row.
    Dim pagerRow As GridViewRow = CustomersGridView.TopPagerRow
    
    ' Retrieve the PageDropDownList DropDownList from the bottom pager
 row.
    Dim pageList As DropDownList = CType(pagerRow.Cells(0).FindControl("PageDropDownList"),
 DropDownList)
        
    ' Set the PageIndex property to display that page selected by the
 user.
    CustomersGridView.PageIndex = pageList.SelectedIndex
    
  End Sub
    
  Sub CustomersGridView_DataBound(ByVal sender
 As Object, ByVal e As
 EventArgs)
    
    ' Get the PagerRow.
    Dim pagerRow As GridViewRow = CustomersGridView.TopPagerRow
    
    ' Retrieve the DropDownList and Label controls from the row.
    Dim pageList As DropDownList = CType(pagerRow.Cells(0).FindControl("PageDropDownList"),
 DropDownList)
    Dim pageLabel As Label = CType(pagerRow.Cells(0).FindControl("CurrentPageLabel"),
 Label)
        
    If Not pageList Is Nothing
 Then
        
      ' Create the values for the DropDownList control based on 
      ' the  total number of pages required to display the data
      ' source.
      Dim i As Integer
            
      For i = 0 To CustomersGridView.PageCount
 - 1
            
        ' Create a ListItem object to represent a page.
        Dim pageNumber As Integer
 = i + 1
        Dim item As ListItem = New
 ListItem(pageNumber.ToString())
            
        ' If the ListItem object matches the currently selected
        ' page, flag the ListItem object as being selected. Because
        ' the DropDownList control is recreated each time the pager
        ' row gets created, this will persist the selected item in
        ' the DropDownList control.   
        If i = CustomersGridView.PageIndex Then
          
          item.Selected = True
                
        End If
            
        ' Add the ListItem object to the Items collection of the 
        ' DropDownList.
        pageList.Items.Add(item)
                
      Next i
        
    End If
        
    If Not pageLabel Is
 Nothing Then
        
      ' Calculate the current page number.
      Dim currentPage As Integer
 = CustomersGridView.PageIndex + 1
        
      ' Update the Label control with the current page information.
      pageLabel.Text = "Page " & currentPage.ToString()
 & _
          " of " & CustomersGridView.PageCount.ToString()
        
    End If
    
  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>GridView TopPagerRow Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource"   
        autogeneratecolumns="true"
        allowpaging="true"
        ondatabound="CustomersGridView_DataBound"
  
        runat="server">
              
        <pagerstyle forecolor="Blue"
          backcolor="LightBlue"/>
          
        <pagersettings position="Top"/>
              
        <pagertemplate>
          
          <table width="100%">             
       
            <tr>                        
              <td width="70%">
                          
                <asp:label id="MessageLabel"
                  forecolor="Blue"
                  text="Select a page:" 
                  runat="server"/>
                <asp:dropdownlist id="PageDropDownList"
                  autopostback="true"
                  onselectedindexchanged="PageDropDownList_SelectedIndexChanged"
 
                  runat="server"/>
                      
              </td>   
                      
              <td width="70%" align="right">
                      
                <asp:label id="CurrentPageLabel"
                  forecolor="Blue"
                  runat="server"/>
                      
              </td>
                                            
            </tr>                    
          </table>
          
        </pagertemplate> 
          
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"
  
        selectcommand="Select [CustomerID], [CompanyName], [Address],
 [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

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

<script runat="server">

  void PageDropDownList_SelectedIndexChanged(Object sender, EventArgs
 e)
  {

    // Retrieve the pager row.
    GridViewRow pagerRow = CustomersGridView.TopPagerRow;
   
    // Retrieve the PageDropDownList DropDownList from the pager row.
    DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");

    // Set the PageIndex property to display that page selected by the
 user.
    CustomersGridView.PageIndex = pageList.SelectedIndex;

  }

  void CustomersGridView_DataBound(Object sender, EventArgs e)
  {
    
    // Retrieve the PagerRow.
    GridViewRow pagerRow = CustomersGridView.TopPagerRow;
    
    // Retrieve the DropDownList and Label controls from the row.
    DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");
    Label pageLabel = (Label)pagerRow.Cells[0].FindControl("CurrentPageLabel");
        
    if(pageList != null)
    {
        
      // Create the values for the DropDownList control based on 
      // the  total number of pages required to display the data
      // source.
      for(int i=0; i<CustomersGridView.PageCount;
 i++)
      {
            
        // Create a ListItem object to represent a page.
        int pageNumber = i + 1;
        ListItem item = new ListItem(pageNumber.ToString()); 
        
            
        // If the ListItem object matches the currently selected
        // page, flag the ListItem object as being selected. Because
        // the DropDownList control is recreated each time the pager
        // row gets created, this will persist the selected item in
        // the DropDownList control.   
        if(i==CustomersGridView.PageIndex)
        {
          item.Selected = true;
        }
            
        // Add the ListItem object to the Items collection of the 
        // DropDownList.
        pageList.Items.Add(item);
                
      }
        
    }
        
    if(pageLabel != null)
    {
        
      // Calculate the current page number.
      int currentPage = CustomersGridView.PageIndex + 1;     
        
      // Update the Label control with the current page information.
      pageLabel.Text = "Page " + currentPage.ToString() +
        " of " + CustomersGridView.PageCount.ToString();
        
    }    
    
  }

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>GridView TopPagerRow Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource"   
        autogeneratecolumns="true"
        allowpaging="true"
        ondatabound="CustomersGridView_DataBound"  
        runat="server">
              
        <pagerstyle forecolor="Blue"
          backcolor="LightBlue"/>
          
        <pagersettings position="Top"/>
              
        <pagertemplate>
          
          <table width="100%">                    
            <tr>                        
              <td width="70%">
                          
                <asp:label id="MessageLabel"
                  forecolor="Blue"
                  text="Select a page:" 
                  runat="server"/>
                <asp:dropdownlist id="PageDropDownList"
                  autopostback="true"
                  onselectedindexchanged="PageDropDownList_SelectedIndexChanged"
 
                  runat="server"/>
                      
              </td>   
                      
              <td width="70%" align="right">
                      
                <asp:label id="CurrentPageLabel"
                  forecolor="Blue"
                  runat="server"/>
                      
              </td>
                                            
            </tr>                    
          </table>
          
        </pagertemplate> 
          
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City],
 [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridView クラス
GridView メンバ
System.Web.UI.WebControls 名前空間
GridView.AllowPaging プロパティ
GridView.BottomPagerRow プロパティ
GridView.FooterRow プロパティ
GridView.HeaderRow プロパティ
GridView.Rows プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からGridView.TopPagerRow プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からGridView.TopPagerRow プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からGridView.TopPagerRow プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

   

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



GridView.TopPagerRow プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS