DataKeyArray.CopyTo メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataKeyArray.CopyTo メソッドの意味・解説 

DataKeyArray.CopyTo メソッド

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

指定した DataKey オブジェクト配列にこのコレクションすべての項目をコピーしますコピー操作は、配列内の指定したインデックス位置から開始されます。

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

解説解説
使用例使用例

CopyTo メソッド使用して、DataKeyArray コレクションDataKey オブジェクトDataKey オブジェクト配列コピーする方法次のコード例示します

<%@ Page language="VB" %>

<script runat="server">

  Sub CustomerGridView_DataBound(ByVal sender
 As Object, ByVal e As
 EventArgs) Handles CustomerGridView.DataBound
          
    ' Use the indexer to retrieve the DataKey object for the 
    ' first record.
    Dim key As DataKey = CustomerGridView.DataKeys(0)

    ' Display the the value of the primary key for the first
    ' record displayed in the GridView control.
    MessageLabel.Text = "The primary key of the first record displayed
 is " & _
      key.Value.ToString() & "."
  
  End Sub
  
</script>

<html>

  <body>
    <form runat="server">
        
      <h3>DataKeyArray Example</h3>
                       
        <asp:gridview id="CustomerGridView"
          datasourceid="CustomerDataSource"
          autogeneratecolumns="true"
          datakeynames="CustomerID"  
          allowpaging="true"
          runat="server">
            
        </asp:gridview>
        
        <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="CustomerDataSource"
          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 CustomerGridView_DataBound(Object sender, EventArgs e)
  {           
    // Use the indexer to retrieve the DataKey object for the 
    // first record.
    DataKey key = CustomerGridView.DataKeys[0];

    // Display the the value of the primary key for the first
    // record displayed in the GridView control.
    MessageLabel.Text = "The primary key of the first record displayed is "
 +
      key.Value.ToString() + ".";
  }
  
</script>

<html>

  <body>
    <form runat="server">
        
      <h3>DataKeyArray Example</h3>
                       
        <asp:gridview id="CustomerGridView"
          datasourceid="CustomerDataSource"
          autogeneratecolumns="true"
          datakeynames="CustomerID"  
          allowpaging="true"
          ondatabound="CustomerGridView_DataBound" 
          runat="server">
            
        </asp:gridview>
        
        <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="CustomerDataSource"
          selectcommand="Select [CustomerID], [CompanyName], [Address], [City],
 [PostalCode], [Country] From [Customers]"
          connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
          runat="server"/>
            
      </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataKeyArray クラス
DataKeyArray メンバ
System.Web.UI.WebControls 名前空間
DataKey クラス
GridView.DataKeys
Item
GetEnumerator



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

辞書ショートカット

すべての辞書の索引

DataKeyArray.CopyTo メソッドのお隣キーワード
検索ランキング

   

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



DataKeyArray.CopyTo メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS