Search code examples
asp.nethtmlcssdataformat

ASP.NET DataBoundField DataFormatString, how can I add html correctly?


I have a DataboundField in a grid. I'm trying to display a date in Euro format and the time. The time should be wrapped in a span with a css class applied to it.

I am using this, DataFormatString="{0:dd/MM/yyyy <\span cla\s\s='tinyDate'>hh:mm:ss</\span>}"

It's actually pretty close, except the span tag is literally rendering in the browser.

In the cell the text looks like this

19/10/2010 <span class=tinyDate>09:35:00</span>

I don't intend to see the span tag, only it's formatted content. How can I remedy this and make it render correctly?

Thanks for any tips or links.

Cheers,
~ck in San Diego


Solution

  • Try setting the HtmlEncode property of the field to "false". It's enabled by default to prevent any malicious client-script code from being executed.