DateTime Formatting in GridView:
Usually we create a field with DataType DateTime in Database
say for eg. MSAccess database.
Now when you show this in the GridView it shows Date along with
time like 7/6/2010 8:10:12 PM
But you may be in situation to show only the Date alone.
like 7/6/2010
To do so, simple specify the format in the GridView BoundField like
<Columns>
<asp:BoundField
DataField="Date1"
HeaderText="Date"
DataFormatString="{0:d}" />
</Columns>
Refer the below link for different other formats
http://msdn.microsoft.com/en-us/library/
system.web.ui.webcontrols.boundfield.dataformatstring.aspx
No comments:
Post a Comment