Thursday, February 7, 2008

Formating Dates in the GridView

I set up a bound GridView. I had several bound fields. A couple of the field were dates. The data source was a date time field. I did not want the time portion, so I used
DataFormatString="{0:MM/dd/yyyy}" on the BoundFields. On my development box it stripped off the time. When I deployed to the server it was still showing the times.

The solution was to add HtmlEncode="False" to the bound fields.