Thursday, January 11, 2007

ASP.Net GridView .Net 2.0

GridView Control.

Problem:
Add HTML to HeaderText

Solution:
Set the attribute HtmlEncode to false

Example:
<asp:BoundField DataField="pk" HeaderText="Primary<br />Key" HtmlEncode="false" />

Comments:
I also found that to add DataFormatString="{0:d}" to work, you'll also have to set the HtmlEncode attribute to false for that given BoundField

Example:
<asp:BoundField DataField="AsOfDate" HeaderText="As Of Date" HtmlEncode="false" DataFormatString="{0:d}">

No comments: