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

DataKey.Values プロパティ

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

DataKey オブジェクト内のすべてのキー フィールド格納されている IOrderedDictionary オブジェクト取得します

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

Public Overridable ReadOnly
 Property Values As IOrderedDictionary
Dim instance As DataKey
Dim value As IOrderedDictionary

value = instance.Values
public virtual IOrderedDictionary Values { get;
 }
public:
virtual property IOrderedDictionary^ Values {
    IOrderedDictionary^ get ();
}
/** @property */
public IOrderedDictionary get_Values ()
public function get Values
 () : IOrderedDictionary

プロパティ
DataKey 内のすべてのキー フィールド格納している IOrderedDictionary

解説解説
使用例使用例

Values プロパティから返される IOrderedDictionary オブジェクト反復処理するコード例次に示します

<%@ Page language="VB" %>

<script runat="server">

  Sub CustomerDetailsView_DataBound(ByVal sender
 As Object, ByVal e As
 EventArgs) Handles CustomerDetailsView.DataBound
    
    ' Retrieve the IOrderedDictionary object that contains the key field
 values.
    Dim allKeysDictionary As IOrderedDictionary
 = CustomerDetailsView.DataKey.Values

    ' Display the the value of the key fields.
    MessageLabel.Text = "The key field values for the displayed
 record are: <br/><br/>"

    ' In Visual Basic, the DictionaryEntry objects contained in the
 
    ' allKeysDictionary object must be copied to an array before
    ' you can iterate through the items.
    Dim allKeysArray(allKeysDictionary.Count - 1) As
 DictionaryEntry
    allKeysDictionary.CopyTo(allKeysArray, 0)
    
    Dim entry As DictionaryEntry
    For Each entry In allKeysArray
     
      MessageLabel.Text &= "Key=" & entry.Key.ToString()
 & _
          ", Value=" & entry.Value.ToString()
 & "<br/>"
    
    Next

  End Sub
  
</script>

<html>

  <body>
    <form runat="server">
        
      <h3>DataKey Example</h3>
                       
        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          autogeneraterows="true"
          datakeynames="CustomerID, CompanyName, PostalCode"
  
          allowpaging="true"
          runat="server">
            
        </asp:detailsview>
        
        <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 CustomerDetailsView_DataBound(Object sender, EventArgs
 e)
  {

    // Retrieve the IOrderedDictionary object that contains the key
 field values.
    IOrderedDictionary allKeysDictionary = CustomerDetailsView.DataKey.Values;

    // Display the the value of the key fields.
    MessageLabel.Text = "The key field values for the displayed
 record are: <br/><br/>";

    foreach (DictionaryEntry entry in allKeysDictionary)
    {
      MessageLabel.Text += "Key=" + entry.Key.ToString() + 
        ", Value=" + entry.Value.ToString() + "<br/>";
    }

  }
  
</script>

<html>

  <body>
    <form runat="server">
        
      <h3>DataKey Example</h3>
                       
        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          autogeneraterows="true"
          datakeynames="CustomerID, CompanyName, PostalCode"  
          allowpaging="true"
          ondatabound="CustomerDetailsView_DataBound" 
          runat="server">
            
        </asp:detailsview>
        
        <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>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataKey クラス
DataKey メンバ
System.Web.UI.WebControls 名前空間
IOrderedDictionary
DataKey.Value プロパティ


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

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

辞書ショートカット

すべての辞書の索引

「DataKey.Values プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS