你怎么能显示一个GridView作为一个日期,而不是只有一个日期时间的日期? [英] How can you show the date in a gridview as a date only instead of a datetime?
本文介绍了你怎么能显示一个GridView作为一个日期,而不是只有一个日期时间的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在日期值从SQL Server数据库中使用GridView和拉动和日期会从
I am pulling in date values from a sql server database using a gridview and and the date gets converted from
12/12/2009 以 2009/12/12上午12时00分〇〇秒
12/12/2009 to 12/12/2009 12:00:00 AM
我如何prevent这种情况发生?
How do I prevent that from happening ?
谢谢!
推荐答案
您可以使用的ToString()
方法用一个面具:
You can use the ToString()
method with a mask:
ToString("MM/dd/yyyy");
更新:只是意识到这将是你的情况更容易做到这一点在网格视图模板
UPDATE: Just realized it would be easier in your case to do this in the grid view template
<asp:BoundField DataField="MyDate" DataFormatString="{0:MM/dd/yyyy}" />
这篇关于你怎么能显示一个GridView作为一个日期,而不是只有一个日期时间的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文