01 June 2011

Hyperlink in SPGridView better than BoundField

I wanted to display a link in an SPGridView. I tried it with a BoundField and an SPBoundField but nothing did the job the right way.

So the solution was to use a HyperLinkField which worked like a charm:

The Data was stored in a DataTable with column names like the names listed below:

HyperLinkField hyperLinkField = new HyperLinkField();
hyperLinkField.DataTextField = "DataField";
hyperLinkField.DataNavigateUrlFields = new string[] { "DataField" };
hyperLinkField.DataNavigateUrlFormatString = "{0}";
hyperLinkField.HeaderText = "My Link Header";
hyperLinkField.SortExpression = "DataField";

0 comments:

Post a Comment