Export (0) Print
Expand All

HyperLinkColumn Class

A column type for the DataGrid control that contains a hyperlink for each item in the column.

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

public ref class HyperLinkColumn : public DataGridColumn
public class HyperLinkColumn extends DataGridColumn
public class HyperLinkColumn extends DataGridColumn
Not applicable.

Use the HyperLinkColumn column type in a DataGrid control to create a hyperlink for each row in the DataGrid. Set the Text property to specify the caption text for the hyperlink. To specify the URL to link to when the hyperlink is clicked, set the NavigateUrl property.

NoteNote:

If you set the Text and NavigateUrl properties, all hyperlinks in the column will share the same caption and URL.

You can also bind the text caption and URL of the hyperlinks in the HyperLinkColumn to a field in a data source instead of setting the Text and NavigateUrl properties. This allows you to display a different caption and to specify a different URL for each hyperlink in the column.

Use the DataTextField property to specify a field in a data source to bind to the text caption of the hyperlinks in the column.

NoteNote:

The DataTextField and Text properties cannot both be set at the same time. If both properties are set, the DataTextField property takes precedence.

Specify the field to bind to the URL of the hyperlink by setting the DataNavigateUrlField property.

NoteNote:

The DataNavigateUrlField and NavigateUrl properties cannot both be set at the same time. If both properties are set, the DataNavigateUrlField property takes precedence.

The Target property allows you to specify the window or frame to display the Web page content linked to when the hyperlink is clicked.

When using data binding, you can format the text caption and URL of the hyperlink by setting the DataTextFormatString and DataNavigateUrlFormatString properties, respectively.

Caution noteCaution:

This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. You can use validation controls to verify user input before displaying the input text in a control. ASP.NET provides an input request validation feature to block script and HTML in user input. For more information, see Securing Standard ControlsHow to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings, and Introduction to Validating User Input in ASP.NET Web Pages.

The following example demonstrates how to create a HyperLinkColumn that links to a separate page.

NoteNote:

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

No code example is currently available or this language may not be supported.

The following corresponding example displays the item selected in the previous example.

No code example is currently available or this language may not be supported.

System.Object
   System.Web.UI.WebControls.DataGridColumn
    System.Web.UI.WebControls.HyperLinkColumn

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft