HyperLinkField.DataTextFormatString プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As HyperLinkField Dim value As String value = instance.DataTextFormatString instance.DataTextFormatString = 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 プロパティを設定しない場合、フィールド値が特に書式変換されずに表示されます。
![]() |
---|
書式指定文字列には、任意のリテラル文字列を使用でき、通常は、フィールド値のプレースホルダが含まれます。たとえば、"Item Value: {0}" という書式指定文字列があった場合、"{0}" のプレースホルダは、対応するフィールドの値と置き換えられた上で、HyperLinkField オブジェクトに表示されます。書式指定文字列の残りの部分は、リテラル テキストとして表示されます。
プレースホルダは、{ A : Bxx } の形式で、中かっこで囲まれた、コロン区切りの 2 つの部分から構成されます。コロンの前の値 (一般的な例での A) は 0 から始まるパラメータのリストのフィールド値インデックスを指定します。
![]() |
---|
このパラメータは、書式指定構文の一部です。各セルはフィールド値を 1 つしか格納できないので、この値は必ず 0 に設定します。 |
コロンおよびコロンの後の値は省略可能です。コロンの後の文字 (一般的な例での B) には、値を表示する際に使用する書式を指定します。共通の書式を次の表に示します。
C | |
D | |
E | |
F | |
G | |
N | |
X |
書式指定文字の後の値 (一般的な例での 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHyperLinkField.DataTextFormatString プロパティを検索する場合は、下記のリンクをクリックしてください。

- HyperLinkField.DataTextFormatString プロパティのページへのリンク