Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cant format datetime using dataformatstring

For some reason i can not format the text of my date in a gridview

<asp:BoundField DataField="deptdate" HeaderText="Departure Date" dataformatstring="{0:ddd, MM/d/yyyy}" htmlencode="False" SortExpression="deptdate" />

I still get this:

May 10 2011 12:00AM

I DID NOT SET MY FIELD TO DATETIME IN THE DATABASE...DOY

like image 375
HELP_ME Avatar asked Apr 26 '11 15:04

HELP_ME


2 Answers

Have you tried this approach?

http://peterkellner.net/2006/05/24/how-to-set-a-date-format-in-gridview-using-aspnet-20using-htmlencode-property/

<asp id="GridView1" runat="server" :GridView>
<columns>
  <asp headertext="CreationDate" dataformatstring="{0:M-dd-yyyy}" 
       datafield="CreationDate" :BoundField HtmlEncode="false" />
</columns>
like image 100
Rob P. Avatar answered Sep 28 '22 08:09

Rob P.


You can use DataFormatString="{0:d}" for short date format in your column definition.

like image 35
Bala R Avatar answered Sep 28 '22 06:09

Bala R