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

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

问题描述

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

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

2009-04-02 00:00:00

我更喜欢他们没有时间展示.我正在使用代码隐藏来获取数据,因此我无法手动更改 gridview 的字段.这是我的 gridview 的所有代码:

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>

如何停止显示时间?

推荐答案

您可以在 gridview 列中应用 dataformatstring 以仅显示日期.

You can apply a dataformatstring in the gridview column to only show the date.

要使其正常工作,您必须确保将 HTMLEncode 设置为 false.

To get it to work you must make sure that HTMLEncode is set to false.

更多信息

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

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