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



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2024 GRAS Group, Inc.RSS