5

出于某种原因,我无法在 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

我没有在数据库中将我的字段设置为日期时间...DOY

4

3 回答 3

8

你试过这种方法吗?

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>
于 2011-04-26T15:33:05.300 回答
2

您可以DataFormatString="{0:d}"在列定义中使用短日期格式。

于 2011-04-26T15:32:46.603 回答
0

自 2013 年第二季度以来,RadHtmlChart 可以数据绑定到 DateTime 对象,因此可以将 XAxis 标签、系列标签和工具提示格式化为所需的日期格式。有关格式化日期的更多信息,请参阅日期轴文章:http ://www.telerik.com/help/aspnet-ajax/htmlchart-date-axis.html

于 2014-02-18T21:16:38.067 回答