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

   在asp.net 1.0 中的datagrid 中 设置日期字段格式时用 DataFormatString="{0:yyyy-MM-dd}"即可。
   今天,我试着在gridview 中设置短日期格式
 <asp:BoundField HeaderText="发表时间" DataField="PostTime" DataFormatString="{0:yyyy-MM-dd}" >
但发现显示效果不对, 页面显示格式为: 2006-11-1 0:00:00

   我试着把 HtmlEncode属性更改。设为HtmlEncode=false. test agin , 哈,搞定。 

完整格式应该是 
<asp:BoundField HeaderText="发表时间" DataField="PostTime"  HtmlEncode=false DataFormatString="{0:yyyy-MM-dd}" >

相关文章:

  • 2021-07-08
  • 2021-12-09
  • 2021-07-10
  • 2022-12-23
猜你喜欢
  • 2022-01-08
  • 2022-12-23
  • 2022-03-08
  • 2021-09-11
相关资源
相似解决方案