Use the HyperLinkColumn class to create a hyperlink for each row in the DataGrid control.
<asp:DataGrid id="accessID" runat="server"
AutoGenerateColumns=false
...
<Columns>
<asp:HyperLinkColumn
DataNavigateUrlField = "DataSourceField"
DataNavigateUrlFormatString = "FormatExpression"
DataTextField = "DataSourceField for HyperLink Caption"
DataTextFormatString = "FormatExpression"
NavigateUrl = "url"
Target = "windowName | _blank | _parent | _self | _top"
Text = "HyperLink Text" />
....
</Columns>
</asp:DataGrid>
| Property |
Description |
| DataNavigateUrlField |
The field or property of the object in DataSource that provides the URL of the page to move to. |
| DataNavigateUrlFormatString |
A format expression to be used with the Text property. |
| DataTextField |
The field or property of the object in DataSource that is the source of data for the Text property of the columns. |
| DataTextFormatString |
The formatting string that specifies how the Text property is displayed in the control. |
| NavigateUrl |
The URL of the page to move to. If DataNavigateUrlField is set, it overrides this property. |
| Target |
The target window that displays the page. This can be the name of a window or a frame reference such as _TOP. |
| Text |
The text of the hyperlink. |
For an example of using a HyperLinkColumn control, see Adding Hyperlink Columns to a DataGrid Web Server Control.
For additonal information, see the HyperLinkColumn Class documentation.