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} | 04 January 2007 | D and d present the same. |
日期 | {0:f} | 04 January 2007 00:00 | |
日期 | {0:F} | 04 January 2007 00:00:00 | |
日期 | {0:s} | 2007-01-04T00:00:00 | |
时间 | {0:T} | 00:00:00 |
设置格式时,须将BoundField.HtmlEncode属性设置为false,才能显示出设定的格式。
日期自定义格式也可支持,格式如下{0:dd-MMM-yyyy},这样灵活很多!