显示日期时,如何停止在GridView中显示的时间? [英] How can I stop the time from displaying in a GridView when displaying a date?

查看:130
本文介绍了显示日期时,如何停止在GridView中显示的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我正在开发的Web应用程序(ASP.NET 2.0和C#)。在其中,我有一个从Oracle数据库获取数据的gridview。我需要显示的一些数据是日期。但是,当我的gridview中的日期显示如下:


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.

More information

这篇关于显示日期时,如何停止在GridView中显示的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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