GridView列数字、货币和日期的显示格式

形式 语法 结果 注释
数字 {0:N2} 12.36  
数字 {0:N0} 13  
货币 {0:c2} $12.36  
货币 {0:c4} $12.3656  
货币 "¥{0:N2}" ¥12.36  
科学计数法 {0:E3} 1.23E+001  
百分数 {0:P} 12.25% P and p present the same.
日期 {0:D} 2006年11月25日  
日期 {0:d} 2006-11-25  
日期 {0:f} 2006年11月25日 10:30  
日期 {0:F} 2006年11月25日 10:30:00  
日期 {0:s} 2006-11-26 10:30:00  
时间 {0:T} 10:30:00
例如:<asp:BoundField DataField="adddate" HeaderText="记录时间" DataFormatString="{0:d}" HtmlEncode="False" />
【注意】需要把HtmlEncode设置为false,才会生效
原文地址:https://www.cnblogs.com/MFxxk/p/1852880.html