Jul 12, 2010

How to show date alone in GridView BoundField when using DateTime as DataType in DataBase.

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

              DataFormatString="{0:d}" />

Refer the below link for different other formats

No comments: