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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > 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



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

辞書ショートカット

すべての辞書の索引

「DetailsViewRowCollection クラス」の関連用語

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

   

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



DetailsViewRowCollection クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS