用DataFormatString格式化GridView
2008-08-27 09:58
399 查看
在GridView里面显示数据,要显示的数据有好多位小数,就想让它只显示两位小数,在delphi里,直接用DisplayFormat就行了,在.net中,使用DataFormatString是可以实现这个功能的,但是怎么设置就不起作用,最后发现,由于2.0出于安全性的考虑,还要同时设置HtmlEncode = false,才能够使DataFormatString生效.
其常用的数值格式如下表所示:
格式字符串 输入 结果
"{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
其常用的数值格式如下表所示:
格式字符串 输入 结果
"{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格式化GridView
- 用DataFormatString格式化GridView
- DataFormatString的格式 GridView数据常用格式化类型
- 用DataFormatString格式化GridView
- 格式化字符串 GridView DataFormatString
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- 很实用的,GridView中使用DataFormatString属性格式化内容
- 用DataFormatString格式化GridView
- GridView日期列使用DataFormatString格式化技巧
- ASP.NET GridView控件在列上格式化时间及DataFormatString使用
- ASP.NET GridView控件在列上格式化时间及DataFormatString使用
- 用DataFormatString格式化GridView
- 用DataFormatString格式化GridView
- asp.net DataFormatString格式化GridView
- Gridview利用DataFormatString属性格式化数据
- 用DataFormatString格式化GridView - .NET,Webservices,Ibastinet,Castle - 博客园
- asp.net DataFormatString格式化GridView