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

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

DetailsView.Rows プロパティ

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

DetailsView コントロールデータ行を表す DetailsViewRow オブジェクトコレクション取得します

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

Public Overridable ReadOnly
 Property Rows As DetailsViewRowCollection
Dim instance As DetailsView
Dim value As DetailsViewRowCollection

value = instance.Rows
public virtual DetailsViewRowCollection Rows { get;
 }
public:
virtual property DetailsViewRowCollection^ Rows {
    DetailsViewRowCollection^ get ();
}
/** @property */
public DetailsViewRowCollection get_Rows ()
public function get Rows
 () : DetailsViewRowCollection

プロパティ
DetailsView コントロール内のすべてのデータ行を格納する DetailsViewRowCollection。

解説解説
使用例使用例

Rows プロパティ使用してDetailsView コントロールデータ行にアクセスする方法コード例次に示しますデータ行は、DetailsView コントロールかフィールド値を取得するために使用されます。

<%@ Page Language="VB" %>

<script runat="server">

  Sub CustomerDetailView_ItemCommand(ByVal
 sender As Object, ByVal
 e As DetailsViewCommandEventArgs)
    
        ' Use the CommandName property to determine which button
        ' was clicked. 
        If e.CommandName = "Add"
 Then

            ' Add the current store to the contact list. 
     
            ' Get the row that contains the store name. In this
            ' example, the store name is in the second row (index 1)
  
            ' of the DetailsView control.
            Dim row As DetailsViewRow = CustomerDetailView.Rows(1)
      
            ' Get the store's name from the appropriate cell.
            ' In this example, the store name is in the second cell
  
            ' (index 1) of the row.
            Dim name As String
 = row.Cells(1).Text

            ' Create a ListItem object with the store's name.
            Dim item As New
 ListItem(name)

            ' Add the ListItem object to the ListBox, if the 
            ' item doesn't already exist.
            If Not ContactListBox.Items.Contains(item)
 Then
      
                ContactListBox.Items.Add(item)
      
            End If
        
        End If
    
    End Sub

</script>

<html>
<body>
    <form id="Form1" runat="server">
        <h3>
            DetailsView ItemCommand Example</h3>
        <asp:DetailsView ID="CustomerDetailView"
 
            DataSourceID="DetailsViewSource"
            AutoGenerateRows="false" 
            DataKeyNames="CustomerID" 
            AllowPaging="true" 
            OnItemCommand="CustomerDetailView_ItemCommand"
            runat="server">
            
            <FieldHeaderStyle BackColor="Navy"
 ForeColor="White" />
            
            <Fields>
                <asp:BoundField DataField="CustomerID"
 HeaderText="Store ID" />
                <asp:BoundField DataField="CompanyName"
 HeaderText="Store Name" />
                <asp:BoundField DataField="City"
 HeaderText="City" />
                <asp:ButtonField CommandName="Add"
 Text="Add Contact" />
            </Fields>
        </asp:DetailsView>
        
        <hr />
        
        Contacts:<br />
        <asp:ListBox ID="ContactListBox" 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"
 runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
            InsertCommand="INSERT INTO [Customers]([CustomerID],
 [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID,
 @CompanyName, @Address, @City, @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<script runat="server">

    void CustomerDetailView_ItemCommand(Object sender, DetailsViewCommandEventArgs
 e)
    {

        // Use the CommandName property to determine which button
        // was clicked. 
        if (e.CommandName == "Add")
        {

            // Add the current store to the contact list. 

            // Get the row that contains the store name. In this
            // example, the store name is in the second row (index 1)
  
            // of the DetailsView control.
            DetailsViewRow row = CustomerDetailView.Rows[1];

            // Get the store's name from the appropriate cell.
            // In this example, the store name is in the second cell
  
            // (index 1) of the row.
            String name = row.Cells[1].Text;

            // Create a ListItem object with the store's name.
            ListItem item = new ListItem(name);

            // Add the ListItem object to the ListBox, if the 
            // item doesn't already exist.
            if (!ContactListBox.Items.Contains(item))
            {
                ContactListBox.Items.Add(item);
            }

        }

    }

</script>

<html>
<body>
    <form id="Form1" runat="server">
        <h3>
            DetailsView ItemCommand Example</h3>
        <asp:DetailsView ID="CustomerDetailView" 
            DataSourceID="DetailsViewSource"
            AutoGenerateRows="false" 
            DataKeyNames="CustomerID" 
            AllowPaging="true" 
            OnItemCommand="CustomerDetailView_ItemCommand"
            runat="server">
            
            <FieldHeaderStyle BackColor="Navy" ForeColor="White"
 />
            
            <Fields>
                <asp:BoundField DataField="CustomerID" HeaderText="Store
 ID" />
                <asp:BoundField DataField="CompanyName" HeaderText="Store
 Name" />
                <asp:BoundField DataField="City" HeaderText="City"
 />
                <asp:ButtonField CommandName="Add" Text="Add Contact"
 />
            </Fields>
        </asp:DetailsView>
        
        <hr />
        
        Contacts:<br />
        <asp:ListBox ID="ContactListBox" 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" runat="server"
 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
            InsertCommand="INSERT INTO [Customers]([CustomerID], [CompanyName],
 [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName,
 @Address, @City, @PostalCode, @Country)"
          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DetailsView クラス
DetailsView メンバ
System.Web.UI.WebControls 名前空間
DetailsViewRow
DetailsViewRowCollection
DetailsView.Fields プロパティ


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

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

辞書ショートカット

すべての辞書の索引

「DetailsView.Rows プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS