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

DataKeyArray クラス

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

DataKey オブジェクトコレクション表します。このクラス継承できません。

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

Public NotInheritable Class
 DataKeyArray
    Implements ICollection, IEnumerable, IStateManager
public sealed class DataKeyArray : ICollection,
 IEnumerable, IStateManager
public ref class DataKeyArray sealed : ICollection,
 IEnumerable, IStateManager
public final class DataKeyArray implements
 ICollection, IEnumerable, 
    IStateManager
public final class DataKeyArray implements
 ICollection, IEnumerable, 
    IStateManager
解説解説
使用例使用例

インデクサ使用して DataKeyArray コレクションから 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 コレクション反復処理する方法次のコード例示します

<%@ Page language="VB" %>

<script runat="server">

  Sub CustomerGridView_DataBound(ByVal sender
 As Object, ByVal e As
 EventArgs) Handles CustomerGridView.DataBound
    
    ' Display the the value of the primary key for each
    ' record in the GridView control.
    MessageLabel.Text = "The primary key of each record displayed
 are: <br/><br/>"

    Dim key As DataKey
    For Each key In CustomerGridView.DataKeys
    
      MessageLabel.Text += key.Value.ToString() + "<br/>"
      
    Next
    
  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)
  {    
    // Display the the value of the primary key for each
    // record in the GridView control.
    MessageLabel.Text = "The primary key of each record displayed are: <br/><br/>";

    foreach (DataKey key in CustomerGridView.DataKeys)
    {
       MessageLabel.Text += key.Value.ToString() + "<br/>";
    }
  }
  
</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>

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

DataKeyArray コンストラクタ

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

DataKeyArray クラス新しインスタンス初期化します。

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

Public Sub New ( _
    keys As ArrayList _
)
Dim keys As ArrayList

Dim instance As New DataKeyArray(keys)
public DataKeyArray (
    ArrayList keys
)
public:
DataKeyArray (
    ArrayList^ keys
)
public DataKeyArray (
    ArrayList keys
)
public function DataKeyArray (
    keys : ArrayList
)

パラメータ

keys

コレクションに項目を挿入するために使用する DataKey オブジェクトの ArrayList。

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

DataKeyArray プロパティ


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

明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Web.UI.IStateManager.IsTrackingViewState DataKeyArray オブジェクトビューステート変更追跡しているかどうかを示す値を取得します
参照参照

関連項目

DataKeyArray クラス
System.Web.UI.WebControls 名前空間
DataKey クラス
ICollection
IStateManager
CopyTo
GetEnumerator
Item
Count

DataKeyArray メソッド


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

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo 指定した System.Array にこのコレクションすべての項目をコピーしますコピー操作は、System.Array 内の指定したインデックス位置から開始されます。
インターフェイスの明示的な実装 System.Web.UI.IStateManager.LoadViewState 以前保存した DataKeyArray オブジェクトビューステート読み込みます。
インターフェイスの明示的な実装 System.Web.UI.IStateManager.SaveViewState DataKeyArray オブジェクト現在のビューステート保存します
インターフェイスの明示的な実装 System.Web.UI.IStateManager.TrackViewState DataKeyArray オブジェクト対すビューステート変更追跡保存始め開始点にマーク付けます
参照参照

関連項目

DataKeyArray クラス
System.Web.UI.WebControls 名前空間
DataKey クラス
ICollection
IStateManager
CopyTo
GetEnumerator
Item
Count

DataKeyArray メンバ

DataKey オブジェクトコレクション表します。このクラス継承できません。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataKeyArray DataKeyArray クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo 指定した System.Array にこのコレクションすべての項目をコピーしますコピー操作は、System.Array 内の指定したインデックス位置から開始されます。
インターフェイスの明示的な実装 System.Web.UI.IStateManager.LoadViewState 以前保存した DataKeyArray オブジェクトビューステート読み込みます。
インターフェイスの明示的な実装 System.Web.UI.IStateManager.SaveViewState DataKeyArray オブジェクト現在のビューステート保存します
インターフェイスの明示的な実装 System.Web.UI.IStateManager.TrackViewState DataKeyArray オブジェクト対すビューステート変更追跡保存始め開始点にマーク付けます
インターフェイスの明示的な実装 System.Web.UI.IStateManager.IsTrackingViewState DataKeyArray オブジェクトビューステート変更追跡しているかどうかを示す値を取得します
参照参照

関連項目

DataKeyArray クラス
System.Web.UI.WebControls 名前空間
DataKey クラス
ICollection
IStateManager
CopyTo
GetEnumerator
Item
Count


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

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

辞書ショートカット

すべての辞書の索引

「DataKeyArray」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS