GridViewRowCollectionとは? わかりやすく解説

GridViewRowCollection クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

GridView コントロール内の GridViewRow オブジェクトのコレクションを表します。

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

Public Class GridViewRowCollection
    Implements ICollection, IEnumerable
Dim instance As GridViewRowCollection
public class GridViewRowCollection : ICollection,
 IEnumerable
public ref class GridViewRowCollection : ICollection,
 IEnumerable
public class GridViewRowCollection implements
 ICollection, IEnumerable
public class GridViewRowCollection implements
 ICollection, IEnumerable
解説解説
使用例使用例

GridView コントロールの Rows コレクションを反復処理して、ページの列の値を表示する方法を次の例に示します。

<%@ Page language="VB" %>

<script runat="server">

  Sub AuthorsGridView_RowCreated(ByVal sender
 As Object, ByVal e As
 GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.Footer Then
      
      ' Get the number of items in the Rows collection.
      Dim count As Integer
 = AuthorsGridView.Rows.Count

      ' If the GridView control contains any records, display 
      ' the last name of each author in the GridView control.
      If count > 0 Then
           
        Message.Text = "The authors are:<br>"
        
        Dim row As GridViewRow
        For Each row In
 AuthorsGridView.Rows
        
          Message.Text &= row.Cells(0).Text & "<br>"
        
        Next
        
      End If
        
    End If
        
  End Sub

</script>

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

      <table>
        <tr>
          <td>
            <asp:gridview id="AuthorsGridView"
 
              datasourceid="AuthorsSqlDataSource"
 
              autogeneratecolumns="false"
              onrowcreated="AuthorsGridView_RowCreated"
  
              runat="server"> 
                     
              <columns>
                <asp:boundfield datafield="au_lname"
                  headertext="Last Name"/>
                <asp:boundfield datafield="au_fname"
                  headertext="First Name"/>
              </columns>
                                    
            </asp:gridview>
          </td>
          <td>
            <asp:label id="Message" 
              forecolor="Red"
              runat="server"/>
          </td>
        </tr>
      </table>
            
      <!-- This example uses Microsoft SQL Server and connects
 -->
      <!-- to the Pubs sample database.                   
     -->
      <asp:sqldatasource id="AuthorsSqlDataSource"
  
        selectcommand="SELECT [au_lname], [au_fname] FROM [authors] WHERE [state]='CA'"
        connectionstring="server=localhost;database=pubs;integrated
 security=SSPI"
        runat="server">
      </asp:sqldatasource>
          
    </form>
  </body>
</html>

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

<script runat="server">

  void AuthorsGridView_RowCreated(Object sender, GridViewRowEventArgs
 e)
  {
    if (e.Row.RowType == DataControlRowType.Footer)
    {      
      
      // Get the number of items in the Rows collection.
      int count = AuthorsGridView.Rows.Count;

      // If the GridView control contains any records, display 
      // the last name of each author in the GridView control.
      if (count > 0)
      {      
        Message.Text = "The authors are:<br>";
        
        foreach (GridViewRow row in AuthorsGridView.Rows)
        {
          Message.Text += row.Cells[0].Text + "<br>";
        }
      }
      
    }
  }

</script>

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

      <table>
        <tr>
          <td>
            <asp:gridview id="AuthorsGridView" 
              datasourceid="AuthorsSqlDataSource" 
              autogeneratecolumns="false"
              onrowcreated="AuthorsGridView_RowCreated"  
              runat="server"> 
                     
              <columns>
                <asp:boundfield datafield="au_lname"
                  headertext="Last Name"/>
                <asp:boundfield datafield="au_fname"
                  headertext="First Name"/>
              </columns>
                                    
            </asp:gridview>
          </td>
          <td>
            <asp:label id="Message" 
              forecolor="Red"
              runat="server"/>
          </td>
        </tr>
      </table>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_lname], [au_fname] FROM [authors] WHERE [state]='CA'"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
          
    </form>
  </body>
</html>

.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.GridViewRowCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridViewRowCollection メンバ
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRow クラス
GridView.Rows プロパティ
CopyTo
Count
GetEnumerator
Item

GridViewRowCollection コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

System.Collections.ArrayList オブジェクトを指定して、GridViewRowCollection クラスの新しいインスタンスを初期化します。

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

Dim rows As ArrayList

Dim instance As New GridViewRowCollection(rows)
public GridViewRowCollection (
    ArrayList rows
)
public:
GridViewRowCollection (
    ArrayList^ rows
)
public GridViewRowCollection (
    ArrayList rows
)
public function GridViewRowCollection (
    rows : ArrayList
)

パラメータ

rows

コレクションを初期化するために使用する GridViewRow オブジェクトを含んだ System.Collections.ArrayList オブジェクト。

解説解説

このコンストラクタは、指定した System.Collections.ArrayList オブジェクトを使用して GridViewRowCollection クラスの新しいインスタンスを初期化するために使用します。System.Collections.ArrayList オブジェクトには、コレクションに項目を挿入するために使用する GridViewRow オブジェクトが保持されています。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GridViewRowCollection クラス
GridViewRowCollection メンバ
System.Web.UI.WebControls 名前空間
System.Collections.ArrayList
GridViewRow クラス

GridViewRowCollection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Count GridViewRowCollection オブジェクト内の項目の数を取得します。
パブリック プロパティ IsReadOnly GridViewRowCollection オブジェクト内の行を変更できるかどうかを示す値を取得します。
パブリック プロパティ IsSynchronized GridViewRowCollection オブジェクトが同期されている (スレッド セーフである) かどうかを示す値を取得します。
パブリック プロパティ Item 指定したインデックス位置にある GridViewRow オブジェクトを取得します。
パブリック プロパティ SyncRoot コレクションへのアクセスを同期するために使用するオブジェクトを取得します。
参照参照

関連項目

GridViewRowCollection クラス
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRow クラス
GridView.Rows プロパティ
CopyTo
Count
GetEnumerator
Item

GridViewRowCollection メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo このメンバの説明については、CopyTo のトピックを参照してください。
参照参照

関連項目

GridViewRowCollection クラス
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRow クラス
GridView.Rows プロパティ
CopyTo
Count
GetEnumerator
Item

GridViewRowCollection メンバ

GridView コントロール内の GridViewRow オブジェクトのコレクションを表します。

GridViewRowCollection データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド GridViewRowCollection System.Collections.ArrayList オブジェクトを指定して、GridViewRowCollection クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count GridViewRowCollection オブジェクト内の項目の数を取得します。
パブリック プロパティ IsReadOnly GridViewRowCollection オブジェクト内の行を変更できるかどうかを示す値を取得します。
パブリック プロパティ IsSynchronized GridViewRowCollection オブジェクトが同期されている (スレッド セーフである) かどうかを示す値を取得します。
パブリック プロパティ Item 指定したインデックス位置にある GridViewRow オブジェクトを取得します。
パブリック プロパティ SyncRoot コレクションへのアクセスを同期するために使用するオブジェクトを取得します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo このメンバの説明については、CopyTo のトピックを参照してください。
参照参照

関連項目

GridViewRowCollection クラス
System.Web.UI.WebControls 名前空間
GridView クラス
GridViewRow クラス
GridView.Rows プロパティ
CopyTo
Count
GetEnumerator
Item



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「GridViewRowCollection」の関連用語

GridViewRowCollectionのお隣キーワード
検索ランキング

   

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



GridViewRowCollectionのページの著作権

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

©2026 GRAS Group, Inc.RSS