asp.net 2.0 中GridView里设置日期格式

来源:互联网 发布:淘宝优惠券网站起名 编辑:程序博客网 时间:2024/05/19 23:59

现在在在gridview 中设置短日期格式

比如要想得到2009年3月23日

如果只是在设这DataFormatString="{0:yyyy年M月d日}"

得到的页面显示效果为: 2009年3月23日 0:00:00 

后面有0:00:00 

如何去掉呢?

 

 必须把 HtmlEncode属性更改。设为HtmlEncode=false

 

完整格式应该是<asp:BoundField HeaderText="发表时间" DataField="PostTime"  HtmlEncode=false DataFormatString="{0:yyyy年M月d日}" >  

原创粉丝点击