cant format datetime using dataformatstring

2019-04-29 19:20发布

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

3条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-29 19:50

Since Q2 2013 the RadHtmlChart can be databound to DateTime objects, so that XAxis Labels, Series Labels and ToolTips can be formatted to the desired date format. More information on formatting dates is available in Date Axis article: http://www.telerik.com/help/aspnet-ajax/htmlchart-date-axis.html

查看更多
老娘就宠你
3楼-- · 2019-04-29 20:04

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>
查看更多
疯言疯语
4楼-- · 2019-04-29 20:10

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

查看更多
登录 后发表回答