Monday, May 19, 2014

C# - Render HTML tags in GridView


HTML Code <b> will not show in the Grid, so need to HTML Decode.

BoundField

<asp:BoundField DataField="MyColumn" HtmlEncode="True" />

ItemTemplate

<ItemTemplate>         
     <asp:Label runat="server"  Text='<%#System.Web.HttpUtility.HtmlEncode(Convert.ToString(Eval("Name"))) %>' /> 
</ItemTemplate> 

No comments:

Post a Comment