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

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

HyperLinkField.DataTextField プロパティ

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

HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションとして使用するテキストが格納されている、データ ソース内のフィールド名を取得または設定します。

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

Public Overridable Property
 DataTextField As String
Dim instance As HyperLinkField
Dim value As String

value = instance.DataTextField

instance.DataTextField = value
public virtual string DataTextField { get;
 set; }
/** @property */
public String get_DataTextField ()

/** @property */
public void set_DataTextField (String value)
public function get DataTextField
 () : String

public function set DataTextField
 (value : String)

プロパティ値
HyperLinkField のハイパーリンクのキャプションとして表示する値が格納されている、データ ソース内のフィールド名。既定値は空の文字列 ("") です。この値は、このプロパティが設定されていないことを示します。

解説解説
使用例使用例

DataTextField プロパティを使用し、HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションにバインドする、データ ソース内のフィールドを指定する方法を次のコード例に示します。

<%@ Page language="VB" %>

<html>
  <body>
    <form runat="server">
        
      <h3>HyperLinkField DataBinding Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- Bind the CompanyName and HomePage fields from the
   -->
      <!-- Northwind database to the caption and
 URL of the    -->
      <!-- hyperlinks in the HyperLinkField field column. Note
 -->
      <!-- that the URLs specified in the Northwind database
   -->
      <!-- might not be valid URLs.                       
     -->
      <asp:gridview id="SuppliersGridView" 
        datasourceid="SuppliersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:hyperlinkfield datatextfield="CompanyName"
            datanavigateurlfields="HomePage"     
     
            headertext="Company Name"
            target="_blank" />
          <asp:boundfield datafield="City" 
            headertext="City"/>
                 
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects
 -->
      <!-- to the Northwind sample database.              
     -->
      <asp:sqldatasource id="SuppliersSqlDataSource"
  
        selectcommand="SELECT [SupplierID], [CompanyName], [City],
 [HomePage] FROM [Suppliers]"
        connectionstring="server=localhost;database=northwind;integrated
 security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<html>
  <body>
    <form runat="server">
        
      <h3>HyperLinkField DataBinding Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- Bind the CompanyName and HomePage fields from the   -->
      <!-- Northwind database to the caption and URL of the    -->
      <!-- hyperlinks in the HyperLinkField field column. Note
 -->
      <!-- that the URLs specified in the Northwind database
   -->
      <!-- might not be valid URLs.                            -->
      <asp:gridview id="SuppliersGridView" 
        datasourceid="SuppliersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:hyperlinkfield datatextfield="CompanyName"
            datanavigateurlfields="HomePage"          
            headertext="Company Name"
            target="_blank" />
          <asp:boundfield datafield="City" 
            headertext="City"/>
                 
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="SuppliersSqlDataSource"  
        selectcommand="SELECT [SupplierID], [CompanyName], [City], [HomePage]
 FROM [Suppliers]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

DataTextFormatString プロパティを使用し、HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションとバインドする値に書式を適用する方法を次のコード例に示します。値には通貨の書式が適用されます。

<%@ Page language="VB" %>

<html>
  <body>
    <form runat="server">
        
      <h3>HyperLinkField DataTextFormatString and DataNavigateUrlFormatString
 Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- The UnitPrice field values are bound to the    
     -->
      <!-- captions of the hyperlinks in
 the HyperLinkField    -->
      <!-- field column, formatted as currency. The ProductID
  -->
      <!-- field values are bound to the navigate URLs of
 the  -->
      <!-- hyperlinks. However, instead of being the actual
    -->
      <!-- URL values, the product ID is passed to
 the linked  -->
      <!-- page as a parameter in the URL
 specified by the     -->
      <!-- DataNavigateUrlFormatString property.          
     -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="Order ID"/>
          <asp:boundfield datafield="ProductID"
 
            headertext="Product ID"/>
          <asp:hyperlinkfield datatextfield="UnitPrice"
            datatextformatstring="{0:c}"
            datanavigateurlfields="ProductID"
            datanavigateurlformatstring="~\details.aspx?ProductID={0}"
          
            headertext="Price"
            target="_blank" />
          <asp:boundfield datafield="Quantity"
 
            headertext="Quantity"/>
                 
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects
 -->
      <!-- to the Northwind sample database.              
     -->
      <asp:sqldatasource id="OrdersSqlDataSource"
  
        selectcommand="SELECT [OrderID], [ProductID], [UnitPrice],
 [Quantity] FROM [Order Details]"
        connectionstring="server=localhost;database=northwind;integrated
 security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<html>
  <body>
    <form runat="server">
        
      <h3>HyperLinkField Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- The UnitPrice field values are bound to the         -->
      <!-- captions of the hyperlinks in the HyperLinkField
    -->
      <!-- field column, formatted as currency. The ProductID  -->
      <!-- field values are bound to the navigate URLs of the  -->
      <!-- hyperlinks. However, instead of being the actual    -->
      <!-- URL values, the product ID is passed to the linked  -->
      <!-- page as a parameter in the URL specified by the
     -->
      <!-- DataNavigateUrlFormatString property.               -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="Order ID"/>
          <asp:boundfield datafield="ProductID" 
            headertext="Product ID"/>
          <asp:hyperlinkfield datatextfield="UnitPrice"
            datatextformatstring="{0:c}"
            datanavigateurlfields="ProductID"
            datanavigateurlformatstring="~\details.aspx?ProductID={0}"
          
            headertext="Price"
            target="_blank" />
          <asp:boundfield datafield="Quantity" 
            headertext="Quantity"/>
                 
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity]
 FROM [Order Details]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HyperLinkField クラス
HyperLinkField メンバ
System.Web.UI.WebControls 名前空間
HyperLinkField.DataNavigateUrlFields プロパティ
HyperLinkField.DataNavigateUrlFormatString プロパティ
DataTextFormatString
NavigateUrl
Target
Text


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

英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「HyperLinkField.DataTextField プロパティ」の関連用語

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

   

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



HyperLinkField.DataTextField プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS