不能使用dataformatstring格式化日期时间 [英] cant format datetime using dataformatstring

查看:267
本文介绍了不能使用dataformatstring格式化日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,我无法在gridview中格式化我的日期文本

 < asp:BoundField DataField = deptdateHeaderText =出发日期dataformatstring ={0:ddd,MM / d / yyyy}htmlencode =FalseSortExpression =deptdate/> 

我仍​​然得到:

2011年5月10日上午12:00

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

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

 < asp id =GridView1runat =服务器:GridView> 
<栏>
< asp headertext =CreationDatedataformatstring ={0:M-dd-yyyy}
datafield =CreationDate:BoundField HtmlEncode =false/>
< / columns>


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

解决方案

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>

这篇关于不能使用dataformatstring格式化日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆