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

Dim instance As HyperLinkField Dim value As String value = instance.DataTextField instance.DataTextField = value
/** @property */ public String get_DataTextField () /** @property */ public void set_DataTextField (String value)
HyperLinkField のハイパーリンクのキャプションとして表示する値が格納されている、データ ソース内のフィールド名。既定値は空の文字列 ("") です。この値は、このプロパティが設定されていないことを示します。

HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションとして使用するテキストが格納されているフィールドの名前を指定するには、DataTextField プロパティを使用します。
このプロパティを使ってハイパーリンクのキャプションをフィールドにバインドする代わりに、Text プロパティを使用して、ハイパーリンクのキャプションを静的な値に設定することもできます。この方法を使用した場合、すべてのハイパーリンクで同じキャプションが共有されます。
![]() |
---|
DataTextField プロパティと Text プロパティの両方が設定されている場合は、DataTextField プロパティが優先されます。 |

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>

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.DataTextField プロパティを検索する場合は、下記のリンクをクリックしてください。

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