显示日期时,如何停止在GridView中显示的时间? [英] How can I stop the time from displaying in a GridView when displaying a date?
问题描述
2009-04-02 00:00:00
我宁愿他们没有时间显示。我正在使用codebehind来获取数据,所以我不能手动改变gridview的字段。这是我的gridview的所有代码:
< asp:GridView ID =Gridrunat =serverEmptyDataText = 没有数据记录显示。 >< / asp:GridView>
如何停止显示时间?
您可以将 gridview
列中的 dataformatstring
应用于显示日期。
要使其正常工作,您必须确保 HTMLEncode
设置为 false
。
I have a web application that I am working on(ASP.NET 2.0 & C#). In it, I have a gridview that gets data from an Oracle Database. Some of the data that I need to display is dates. But when the dates in my gridview show like this:
2009-04-02 00:00:00
I'd prefer they show without the time. I'm using the codebehind to get the data, so I cant alter the fields of the gridview manually. This is all the code for my gridview :
<asp:GridView ID="Grid" runat="server" EmptyDataText="There are no data records to display." ></asp:GridView>
How do I stop the time from displaying?
You can apply a dataformatstring
in the gridview
column to only show the date.
To get it to work you must make sure that HTMLEncode
is set to false
.
这篇关于显示日期时,如何停止在GridView中显示的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!