I am populating a DataTable and then binding this to a GridView control. However, one of the boundfields is a smallDateTime field and the data is being mangled on insertion to the Gridview, how do you overcome this? I have set the boundfield to have formatting but to no avail the dates are still wrong. When I say wrong I mean that, for example, a record contains the date 11/21/2010, in the gridview it is shown as 3/2/2011… how do I correct this?
<asp:boundfield datafield="PubDate" headertext="Last Ad Date"
SortExpression="PubDate" DataFormatString="{0:d}"
HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-Width="75px" HtmlEncode="false">
</asp:boundfield>
Thanks
You’re formatting as Decimal, not SmallDateTime. See, e.g., http://www.csharp-examples.net/string-format-datetime/.