如何仅在网格视图中显示日期? [英] How can i show date only in the grid view ?

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

问题描述

我在文本框中使用了日历扩展器,在表格中输入了日期,并在Grid View中显示了该日期,它同时显示了日期和时间,但是我只想在Grid View中显示日期,所以请告诉我

解决方案

,同时在sql中从表中获取数据时,请使用convert转换为char,然后它不会在网格视图中显示计时

对于例如

 选择 转换(>字符,别名)来自 tblname


或在前端使用convert.Tostring().
您可以使用它来获取日期部分,但是有许多使用语言环境和全球化的方法.

但是简单来说,如果您不担心跨国编程,可以这样做:

 DateTime.Now.ToString(" ) 


 DateTime.Now.ToString(" ) 



如果要使用语言环境设置,可以尝试:

 DateTime.Now.ToShortDateString()


 DateTime.Now.ToLongDateString()


i used a calender extender with the text box to enter the date into table and showing that date in the Grid View and it shows both date and time but i want to show date only in the grid view so please tell me what i need to do?

解决方案

while fetching the data from table in sql use convert to char, then it won''t show timing in the grid view

for eg

select convert(char,colmname) from tblname


or use convert.Tostring() in front end.


The DateTime object in .Net has a ToString method with a large number of overrides.

You can use this to get just the date part but there are many ways using locales and globalization.

But in the simplest term, if you''re not worry about multi national programming you could do this:

DateTime.Now.ToString("dd/MM/yyyy")

or

DateTime.Now.ToString("MM-dd-yyyy")



If you want to use the locale settings you could try:

DateTime.Now.ToShortDateString()

or

DateTime.Now.ToLongDateString()


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

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