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}" >
今天,我试着在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}" >