Rod Rod - 1 year ago 88
ASP.NET (C#) Question

My data table has some html elements in it, how to databind as html

One of my columns in my data table contains a value like the following:

<strong>Hello World</strong>

How do I databind that to my GridView so it will show bold and not the words strong?

Answer Source

It seems using the BoundField will put out the Entity characters instead of the actual characters (e.g. &lt; instead of <). I've tested this and it seems to work if you just Eval your column in a TemplateColumn like so:

<asp:TemplateField HeaderText="Link">
        <%# Eval("MyField") %>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download