大家在用 GridView 绑定时间字段时需要把时间格式化成想要的格式比如:DataFormatString="{0:yyyy-MM-dd}";
但得到的效果仍然时默认的全部显示格式,为什么呢时因为您少设置了一项 htmlencode属性,默认时true,把此属性更改为false即可!如:
<asp:BoundField DataField="SendTime"
SortExpression="SendTime" HtmlEncode="false"
DataFormatString="{0:yyyy-MM-dd}">
</asp:BoundField>
本文介绍如何在使用ASP.NET GridView控件时正确地格式化日期时间字段。通过设置DataFormatString和HtmlEncode属性,可以实现自定义的时间显示格式。
709

被折叠的 条评论
为什么被折叠?



