Search code examples
telerik-grid

Telerik GridBoundColumn DataFormatString is ignored


I am using a telerik grid, and am trying to format a date column, but it's not working. The DataFormatString is ignored, no matter what I put in it.

<telerik:GridBoundColumn DataField="myDate" HeaderText="My Date"
            SortExpression="myDate" HeaderStyle-Wrap="false" ItemStyle-VerticalAlign="Top"
            UniqueName="myDate" DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="true" />

Why is the DataFormatString being totally ignored?


Solution

  • When the HTMLEncode property is set to true, the DataFormatString property is ignored. Since this is a date and you are controlling the format of the output, there's no reason to set the HTMLEncode property anyway.