Gridview边界域中的日期格式 [英] Date Format in Gridview Boundfields
本文介绍了Gridview边界域中的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,我正在使用gridview并使用绑定字段和sqldatasource来显示数据。
这个我有一个名字为Creation Date的coulmn。
< asp:BoundField DataField = CreationDate HeaderText = CreationDate
SortExpression = CreationDate />
但显示日期为2013年1月13日12:00:00。
在这里,我想只显示日期为13/1/2013
请帮助我解决这个问题。
谢谢。
解决方案
试试这个:
< asp:boundfield datafield = Your_Date_Column dataformatstring = {0: d} htmlencode = false / >
如需其他格式,请查看以下链接:
如何设定日期格式 - in-gridview.html [ ^ ]
日期格式化在CSharp中 [ ^ ] 块quote>
您可以使用 BoundField。 DataFormatString属性 [ ^ ]指定字段值的显示格式。
< asp:boundfield datafield = CreationDate headertext = CreationDate sortexpression = Creati onDate dataformatstring = {0:dd / MM / yyyy} / >
hi friends, am working on gridview and am using bound fields and sqldatasource to display the data.
in this i have one coulmn with name Creation Date.
<asp:BoundField DataField="CreationDate" HeaderText="CreationDate" SortExpression="CreationDate"/>
But it is displaying date as 1/13/2013 12:00:00 AM.
here i want to display only date as 13/1/2013
Please help me and solve this.
Thanks.解决方案Try this:
<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:d}" htmlencode="false" />
For other formats look into below link:
how-to-set-date-format-in-gridview.html[^]
Date-Formatting-in-CSharp[^]
You can use BoundField.DataFormatString Property[^] to specify the display format for the value of the field.
<asp:boundfield datafield="CreationDate" headertext="CreationDate" sortexpression="CreationDate" dataformatstring="{0:dd/MM/yyyy}" />
这篇关于Gridview边界域中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文