• GridView中设置DataFormatString无效的解决方法


    如果直接设置DataFormatString为{0:d}浏览会发现并不会呈现预期的效果.
    还要在HtmlEncode中把值设为False如图.
    PS:
    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 

    完整日期时间格式 
    (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
  • 相关阅读:
    (Good Bye 2019) Codeforces 1270B Interesting Subarray
    (Good Bye 2019) Codeforces 1270A Card Game
    Codeforces 1283D Christmas Trees(BFS)
    Codeforces 1283C Friends and Gifts
    Codeforces 1283B Candies Division
    1095 Cars on Campus (30)
    1080 Graduate Admission (30)
    1099 Build A Binary Search Tree (30)
    1018 Public Bike Management (30)
    1087 All Roads Lead to Rome (30)
  • 原文地址:https://www.cnblogs.com/zhuawang/p/725943.html
Copyright © 2020-2023  润新知