在asp.net gridview的日期时间格式 [英] datetime format in asp.net gridview

查看:182
本文介绍了在asp.net gridview的日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的GridView控件来显示日期时间列,但我不希望显示肯定米林第二。我如何设置GridView控件来显示下列格式datetime数据格式字符串:
2007年8月19日上午11:09

I need to display a datetime column in my gridview, but I don't want to show millin second for sure. How do I set the format string in gridview to display a datetime data in following format: 08-19-2007 11:09 AM

推荐答案

使用适当的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx\"><$c$c>DataFormatString为绑定字段。

Use the appropriate DataFormatString for the bound field.

<asp:BoundField DataField="YourDateField" HeaderText="SomeHeader" 
                    DataFormatString="{0:MM-dd-yyyy hh:mm tt}"  />

另外,你可以使用 DateFormatString ={0:绿}这是一般的日期/时间模式(短时间)。它会产生类似 2007年8月19日上午11:09

Alternatively, you could use DateFormatString="{0:g}" which is the general date/time pattern (short time). It would produce something like 08/19/2007 11:09 AM

这篇关于在asp.net gridview的日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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