HyperLinkField.Text Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the text to display for each hyperlink in the HyperLinkField object.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual string Text { get; set; }

Property Value

Type: System.String

The text to display for each hyperlink in the HyperLinkField. The default is an empty string (""), which indicates that this property is not set.

Use the Text property to specify the caption to display for the hyperlinks in a HyperLinkField object. When this property is set, each hyperlink shares the same caption.

Instead of using this property to set the hyperlink captions, you can use the DataTextField property to bind the hyperlink captions to a field in a data source. This allows you to display a different caption for each hyperlink.


If the DataTextField and Text properties are both set, the DataTextField property takes precedence.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

The following code example demonstrates how to use the Text property to specify a static caption to display for the hyperlinks in a HyperLinkField object.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>HyperLinkField Example</title>
    <form id="form1" runat="server">

      <h3>HyperLinkField Example</h3>

      <!-- Populate the Columns collection declaratively. -->
      <!-- Set the HyperLinkField field column to a static     -->
      <!-- caption and URL.                                    -->
      <asp:gridview id="OrdersGridView" 


          <asp:boundfield datafield="OrderID" 
          <asp:boundfield datafield="CustomerID" 
            headertext="Customer ID"/>
          <asp:boundfield datafield="OrderDate" 
            headertext="Order Date"
            dataformatstring="{0:d}" />
          <asp:hyperlinkfield text="Details..."
            headertext="Order Details"
            target="_blank" />



      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [CustomerID], [OrderDate] FROM [Orders]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"


.NET Framework
Available since 2.0
Return to top