Friday, April 24, 2009

Guide to the HyperLinkField

If we use GridViewin asp.net, we see Hyperlinkfield, at first time we thought that it is very
easy to use but at another second we get confuse how to use it so I am going to focus on using it in a Gridview which is populated from database
the main thing of HyperLinkField is work like a regular hyperlink in our GridView.

The main four properties are here concerned are:
1). DataTextField,
2). HeaderText,
3). DataNavigateURLFields,
4). DataNavigateUrlFormatString.

I discuss all the properties one by one let me start from the simplest one i.e. Headertext, which appears in the Header of the GridView, we can set as our wish because it will not effect our data retrieval.
In a GridView condition, we have a field which will will act as the Hyperlink text

like Data comes from DataTextField

for Querystring we are going to use DataNavigateUrlFields and for the page we want to jump we use DataNavigateUrlFormatString

Example: