Display Date Format in GridView ASP.Net

Sometime you may want to display a Date on a Grid view on your ASP.Net application. When you retrieve the data from database, which is in Date Format.
It often displays date and time together and may not display it into the correct format you want. E.g. 21-12-2009 00:00:00 rather than 21-12-2009…etc

The get around this problem:
You just need to add one attribute on your code on the .aspx file
DataFormatString=”{0:dd-MM-yyyy}” />

Hope you find it useful.

Leave a Reply