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

DataKey.Value プロパティ

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

DataKey オブジェクト内のインデックス 0 にあるキー フィールドの値を取得します

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

解説解説
使用例使用例

Value プロパティ使用してレコード主キーの値を確認するコード例次に示します

<%@ Page language="VB" %>

<script runat="server">

  Sub CustomerDetailsView_DataBound(ByVal sender
 As Object, ByVal e As
 EventArgs) Handles CustomerDetailsView.DataBound

    ' Get the DataKey object for the current record.
    Dim key As DataKey = CustomerDetailsView.DataKey
    
    ' Display the the value of the key field.
    MessageLabel.Text = "The key field value for the displayed
 record is " & _
      key.Value.ToString() & "."
    
  End Sub
  
</script>

<html>

  <body>
    <form runat="server">
        
      <h3>DataKey Example</h3>
                       
        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          autogeneraterows="true"
          datakeynames="CustomerID"  
          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)
  {
    // Get the DataKey object for the current record.
    DataKey key = CustomerDetailsView.DataKey;
    
    // Display the the value of the key field.
    MessageLabel.Text = "The key field value for the displayed
 record is " + 
      key.Value.ToString() + ".";
  }
  
</script>

<html>

  <body>
    <form runat="server">
        
      <h3>DataKey Example</h3>
                       
        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          autogeneraterows="true"
          datakeynames="CustomerID"  
          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 名前空間
Values


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

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS