GridView, DataGrid 中,DataFormatString语法汇总
来源:互联网 发布:淘宝哪家mk代购是正品 编辑:程序博客网 时间:2024/06/06 18:53
有个时间要在gridview中显示,但是保持着数据库中的是标准时间,很长,而且只需要显示日期,就想要格式化字符串,可是设置了DataFormatString就是不起作用,后来一查,原来要设置"行为"中HtmlEncode = false
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
最后写一下中国常用的格式
{0:yyyy-MM-dd}
{0:yyyy年 MM月 dd日}
- GridView, DataGrid 中,DataFormatString语法汇总
- GridView, DataGrid 中,DataFormatString语法汇总
- GridView, DataGrid 中,DataFormatString语法汇总 - Jack @ CnBlogs - 博客园
- GridView 中 DataFormatString
- GridView 中 DataFormatString 的使用
- GridView 中 DataFormatString 的使用
- GridView 中 DataFormatString 的使用
- 在GridView中设置DataFormatString
- GridView 中 DataFormatString 的使用
- Datagrid DataFormatString
- GridView中设置DataFormatString无效的解决方法
- GridView中设置DataFormatString无效的解决方法
- 2005中关于在GridView 的DataFormatString属性
- ASP.NET 2.0中Gridview利用DataFormatString属性设置数据格式
- ASP.NET 2.0中Gridview利用DataFormatString属性设置数据格式
- GridView中Dataformatstring 格式化日期应注意的问题
- ASP.NET 2.0中Gridview利用DataFormatString属性设置数据格式
- C# GridView中DataFormatString属性的取值
- Android拍照上传代码样例
- VC++ 遇到链接错误LNK2001
- UNIX环境高级编程学习之第十一章线程-线程的创建、退出、等待、取消、分离
- IE首页被恶意篡改的十二种解决方法
- DirectFB窗口管理器(unique)研究笔记
- GridView, DataGrid 中,DataFormatString语法汇总
- DataSet和DataTable
- Linux图形界面中客户端、服务器、窗口管理器之间的关系
- RMQ问题与LCA问题
- XCOPY
- STL
- VC++与Matlab混合编程的快速实现
- const使用详解
- 闪屏效果