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

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

HyperLinkField.DataTextFormatString プロパティ

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

HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションに適用する書式指定文字列を取得または設定します。

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

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

value = instance.DataTextFormatString

instance.DataTextFormatString = value
public virtual string DataTextFormatString
 { get; set; }
public:
virtual property String^ DataTextFormatString {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_DataTextFormatString ()

/** @property */
public void set_DataTextFormatString (String
 value)
public function get DataTextFormatString
 () : String

public function set DataTextFormatString
 (value : String)

プロパティ値
HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションに適用する書式指定文字列。既定値は空の文字列です ("")。この値は、ハイパーリンクのキャプションに適用される特定の書式が設定されていないことを示します。

解説解説

HyperLinkField オブジェクトに表示するキャプションのカスタムの表示形式を指定するには、DataTextFormatString プロパティを使用します。DataTextFormatString プロパティを設定しない場合、フィールド値が特に書式変換されずに表示されます。

メモメモ

DataTextField プロパティを設定した場合に限り、書式指定文字列は適用されます。

書式指定文字列には、任意のリテラル文字列を使用でき、通常は、フィールド値のプレースホルダが含まれます。たとえば、"Item Value: {0}" という書式指定文字列があった場合、"{0}" のプレースホルダは、対応するフィールドの値と置き換えられた上で、HyperLinkField オブジェクトに表示されます。書式指定文字列の残りの部分は、リテラル テキストとして表示されます。

プレースホルダは、{ A : Bxx } の形式で、中かっこで囲まれた、コロン区切りの 2 つの部分から構成されます。コロンの前の値 (一般的な例での A) は 0 から始まるパラメータのリストのフィールド値インデックスを指定します。

メモメモ

このパラメータは、書式指定構文の一部です。各セルはフィールド値を 1 つしか格納できないので、この値は必ず 0 に設定します。

コロンおよびコロンの後の値は省略可能です。コロンの後の文字 (一般的な例での B) には、値を表示する際に使用する書式を指定します。共通の書式を次の表に示します。

書式指定文字の後の値 (一般的な例での xx) は、表示する有効桁数または小数点を指定します。たとえば、書式指定文字列 "{0:F2}" を使用すると、2 桁の固定小数点数で表示されます。

書式指定文字列の詳細については、「書式設定の概要」を参照してください。

使用例使用例

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 プロパティ
HyperLinkField.DataTextField プロパティ
NavigateUrl
Target
Text


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

英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2026 GRAS Group, Inc.RSS