I have a datetime datatype field in mssql2005 database ...开发者_如何学Go
which retrieves the date in gridview as .. 4/7/2011 12:00:00 AM
but i want it retrieve date as 7-Apr-2011
how to do this ?
If this is in a BoundField, try this:
<asp:boundfield datafield="YourDateColumn" dataformatstring="{0:d-MMM-yyyy}" />
You may also go this way;
String.Format("{0:d-MMM-yyyy}", DateTime.Now)
or even;
DateTime.Now.ToString("d-MMM-yyyy");
精彩评论