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

DetailsViewRowCollection クラス

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

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

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

Public Class DetailsViewRowCollection
    Implements ICollection, IEnumerable
Dim instance As DetailsViewRowCollection
public class DetailsViewRowCollection : ICollection,
 IEnumerable
public ref class DetailsViewRowCollection :
 ICollection, IEnumerable
public class DetailsViewRowCollection implements
 ICollection, IEnumerable
public class DetailsViewRowCollection implements
 ICollection, IEnumerable
解説解説

DetailsViewRowCollection クラスは、DetailsView コントロール内の DetailsViewRow オブジェクトのコレクションを格納および管理する場合に使用されます。DetailsView コントロール内の各行は DetailsViewRow オブジェクトで表されます。DetailsView コントロールは、その Rows プロパティに対して DetailsViewRowCollection クラスを使用します。

メモメモ

Rows プロパティには、データ行だけが格納されます。ヘッダー行、フッター行、上部のページ行、および下部のページ行にアクセスするには、それぞれ HeaderRow、FooterRow、TopPagerRow、および BottomPagerRow の各プロパティを使用します。

DetailsViewRowCollection クラスは、コレクション内の項目にアクセスするための複数の方法をサポートしています。

コレクション内の合計項目数を確認するには、Count プロパティを使用します。

使用例使用例

DetailsView コントロールの Rows コレクション内の DetailsViewRow オブジェクトを反復処理する方法のコード例を次に示します。このコード例では、各行の値がページに表示されます。

<%@ page language="VB" %>

<script runat="server">

  Sub SubmitButton_Click(ByVal sender As
 Object, ByVal e As EventArgs)
 
    ' Use the Count property to determine whether the
    ' Rows collection contains any item.
    If ItemDetailsView.Rows.Count > 0 Then
    
      ' Iterate through the Rows collection and display
      ' the value of each field.
      MessageLabel.Text = "The row values are: <br/><br/>"
    
      Dim row As DetailsViewRow
    
      For Each row In ItemDetailsView.Rows
    
        ' Use the Text property to access the value of 
        ' each cell. In this example, the cells in the 
        ' first column (index 0) contains the field names, 
        ' while the cells in the second column (index 1)
        ' contains the field value. 
        MessageLabel.Text &= row.Cells(0).Text & " = "
 & _
          row.Cells(1).Text & "<br/>"
    
      Next
    
    Else
      
      MessageLabel.Text = "No items."
    
    End If
    
  End Sub
  
</script>

<html>
  <body>
    <form runat="server">
    
      <h3>DetailsViewRowCollection Example</h3>
  
      <asp:detailsview id="ItemDetailsView"
        datasourceid="DetailsViewSource"
        allowpaging="true"
        autogeneraterows="false" 
        runat="server">
        <fields>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID"/>
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </fields>
      </asp:detailsview>
      
      <br/>
      
      <asp:button id="SubmitButton" 
        text="Display Row Values"
        onclick="SubmitButton_Click"
        runat="server"/>
        
      <br/><br/>
      
      <asp:label id="MessageLabel"
        forecolor="Red"
        runat="server"/>
      
      <!-- 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="DetailsViewSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], 
          [City], [PostalCode], [Country] From [Customers]"
        connectionstring=
          "<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>  
  
    </form>
  </body>
</html>
<%@ page language="C#" %>

<script runat="server">

  void SubmitButton_Click(Object sender, EventArgs e)
  {

    // Use the Count property to determine whether the
    // Rows collection contains any item.
    if (ItemDetailsView.Rows.Count > 0)
    {
      // Iterate through the Rows collection and display
      // the value of each field.
      MessageLabel.Text = "The row values are: <br/><br/>";

      foreach (DetailsViewRow row in ItemDetailsView.Rows)
      {
        // Use the Text property to access the value of 
        // each cell. In this example, the cells in the 
        // first column (index 0) contains the field names, 
        // while the cells in the second column (index 1)
        // contains the field value. 
        MessageLabel.Text += row.Cells[0].Text + " = " +
          row.Cells[1].Text + "<br/>";
      }
    }
    else
    {
      MessageLabel.Text = "No items.";
    }

  }
  
</script>

<html>
  <body>
    <form runat="server">
    
      <h3>DetailsViewRowCollection Example</h3>
  
      <asp:detailsview id="ItemDetailsView"
        datasourceid="DetailsViewSource"
        allowpaging="true"
        autogeneraterows="false" 
        runat="server">
        <fields>
          <asp:boundfield datafield="CustomerID"
            headertext="Customer ID"/>
          <asp:boundfield datafield="CompanyName"
            headertext="Company Name"/>
          <asp:boundfield datafield="Address"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            headertext="Country"/>
        </fields>
      </asp:detailsview>
      
      <br/>
      
      <asp:button id="SubmitButton" 
        text="Display Row Values"
        onclick="SubmitButton_Click"
        runat="server"/>
        
      <br/><br/>
      
      <asp:label id="MessageLabel"
        forecolor="Red"
        runat="server"/>
      
      <!-- 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="DetailsViewSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], 
          [City], [PostalCode], [Country] From [Customers]"
        connectionstring=
          "<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>  
  
    </form>
  </body>
</html>
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.DetailsViewRowCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DetailsViewRowCollection メンバ
System.Web.UI.WebControls 名前空間
DetailsView クラス
DetailsViewRow クラス
DetailsView.Rows プロパティ
DetailsView.HeaderRow プロパティ
DetailsView.FooterRow プロパティ
DetailsView.TopPagerRow プロパティ
DetailsView.BottomPagerRow プロパティ
Count
Item
CopyTo
GetEnumerator

DetailsViewRowCollection コンストラクタ

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

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

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

Dim rows As ArrayList

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

パラメータ

rows

コレクションを初期化するために使用する DetailsViewRow オブジェクトを格納している ArrayList。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DetailsViewRowCollection クラス
DetailsViewRowCollection メンバ
System.Web.UI.WebControls 名前空間
DetailsView クラス
DetailsViewRow クラス
ArrayList
DetailsView.Rows プロパティ

DetailsViewRowCollection プロパティ


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

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

関連項目

DetailsViewRowCollection クラス
System.Web.UI.WebControls 名前空間
DetailsView クラス
DetailsViewRow クラス
DetailsView.Rows プロパティ
DetailsView.HeaderRow プロパティ
DetailsView.FooterRow プロパティ
DetailsView.TopPagerRow プロパティ
DetailsView.BottomPagerRow プロパティ
Count
Item
CopyTo
GetEnumerator

DetailsViewRowCollection メソッド


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

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo この DetailsViewRowCollection オブジェクトのすべての項目を、指定された Array オブジェクトにコピーします。コピー操作は、Array の指定されたインデックス位置から始まります。
参照参照

関連項目

DetailsViewRowCollection クラス
System.Web.UI.WebControls 名前空間
DetailsView クラス
DetailsViewRow クラス
DetailsView.Rows プロパティ
DetailsView.HeaderRow プロパティ
DetailsView.FooterRow プロパティ
DetailsView.TopPagerRow プロパティ
DetailsView.BottomPagerRow プロパティ
Count
Item
CopyTo
GetEnumerator

DetailsViewRowCollection メンバ

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

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


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

関連項目

DetailsViewRowCollection クラス
System.Web.UI.WebControls 名前空間
DetailsView クラス
DetailsViewRow クラス
DetailsView.Rows プロパティ
DetailsView.HeaderRow プロパティ
DetailsView.FooterRow プロパティ
DetailsView.TopPagerRow プロパティ
DetailsView.BottomPagerRow プロパティ
Count
Item
CopyTo
GetEnumerator



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「DetailsViewRowCollection」の関連用語

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

   

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



DetailsViewRowCollectionのページの著作権

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

©2026 GRAS Group, Inc.RSS