DataFormatString的格式化
来源:互联网 发布:农村淘宝,报名. 编辑:程序博客网 时间:2024/04/29 17:58
DataFormatString 属性语法如下:
DataFormatString="{0:格式字符串}"
我们知道在DataFormatString 中的 {0} 表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式;另外在指定的格式符号后可以指定小数所要显示的位数。例如原来的数据为「1.56」,若格式设定为 {0:N1},则输出为「1.5」。其常用的数值格式如下表所示:
格式字符串 输入 结果
"{0:C}" 12345.6789 $12,345.68
"{0:C}" -12345.6789 ($12,345.68)
"{0:D}" 12345 12345
"{0:D8}" 12345 00012345
"{0:E}" 12345.6789 1234568E+004
"{0:E10}" 12345.6789 1.2345678900E+004
"{0:F}" 12345.6789 12345.68
"{0:F0}" 12345.6789 12346
"{0:G}" 12345.6789 12345.6789
"{0:G7}" 123456789 1.234568E8
"{0:N}" 12345.6789 12,345.68
"{0:N4}" 123456789 123,456,789.0000
"Total: {0:C}" 12345.6789 Total: $12345.68
其常用的日期格式如下表所示:
格式 说明 输出格式
d 精简日期格式 MM/dd/yyyy
D 详细日期格式 dddd, MMMM dd, yyyy
f 完整格式 (long date + short time) dddd, MMMM dd, yyyy HH:mm
F
完整日期时间格式
(long date + long time)
dddd, MMMM dd, yyyy HH:mm:ss
g 一般格式 (short date + short time) MM/dd/yyyy HH:mm
G 一般格式 (short date + long time) MM/dd/yyyy HH:mm:ss
m,M 月日格式 MMMM dd
s 适中日期时间格式 yyyy-MM-dd HH:mm:ss
t 精简时间格式 HH:mm
T 详细时间格式 HH:mm:ss
DataFormatString="{0:格式字符串}"
我们知道在DataFormatString 中的 {0} 表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式;另外在指定的格式符号后可以指定小数所要显示的位数。例如原来的数据为「1.56」,若格式设定为 {0:N1},则输出为「1.5」。其常用的数值格式如下表所示:
格式字符串 输入 结果
"{0:C}" 12345.6789 $12,345.68
"{0:C}" -12345.6789 ($12,345.68)
"{0:D}" 12345 12345
"{0:D8}" 12345 00012345
"{0:E}" 12345.6789 1234568E+004
"{0:E10}" 12345.6789 1.2345678900E+004
"{0:F}" 12345.6789 12345.68
"{0:F0}" 12345.6789 12346
"{0:G}" 12345.6789 12345.6789
"{0:G7}" 123456789 1.234568E8
"{0:N}" 12345.6789 12,345.68
"{0:N4}" 123456789 123,456,789.0000
"Total: {0:C}" 12345.6789 Total: $12345.68
其常用的日期格式如下表所示:
格式 说明 输出格式
d 精简日期格式 MM/dd/yyyy
D 详细日期格式 dddd, MMMM dd, yyyy
f 完整格式 (long date + short time) dddd, MMMM dd, yyyy HH:mm
F
完整日期时间格式
(long date + long time)
dddd, MMMM dd, yyyy HH:mm:ss
g 一般格式 (short date + short time) MM/dd/yyyy HH:mm
G 一般格式 (short date + long time) MM/dd/yyyy HH:mm:ss
m,M 月日格式 MMMM dd
s 适中日期时间格式 yyyy-MM-dd HH:mm:ss
t 精简时间格式 HH:mm
T 详细时间格式 HH:mm:ss
- DataFormatString的格式化
- DataFormatString格式化字符串的总结
- DataFormatString格式化字符串的总结
- DataFormatString格式化字符串的总结
- DataFormatString格式化
- DataFormatString格式化
- 关于gridView格式化数据的说明 DataFormatString
- DataFormatString--格式化字符串
- 用DataFormatString格式化GridView
- DataFormatString--格式化字符串
- DataFormatString格式化列信息
- DataFormatString--格式化字符串
- 用DataFormatString格式化GridView
- DataFormatString--格式化字符串
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- VS2005调试问题解决方案集锦--引用
- Lua 标准库 - 基本函数(base function)
- [JS]详尽解析window.event对象
- 要在vs2005中实现最基本的打印文本基本上需要以下几个步骤
- ThinkKey 人生
- DataFormatString的格式化
- omnet图中选择显示不同的图片
- Ruby on Rails案例学习:ChangingThePresent.org
- HTML与JS互转工具
- linux常见压缩方式
- oracle一些优化的方法
- 在b/s开发中经常用到的javascript技术
- 写得蛮好的linux学习笔记
- 数据绑定DataBinder.Eval使用总结