zoukankan      html  css  js  c++  java
  • DataFormatString的使用 griview

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:BoundField DataField="RealDiscountRate" HeaderText="折扣率(%)" SortExpression="RealDiscountRate"
    DataFormatString
    ="{0:0.0%}" ItemStyle-HorizontalAlign="center">
    <ItemStyle Width="10%" />
    </asp:BoundField>
    //这个是上面convert后的样式
    <
    asp:TemplateField HeaderText="折扣率(%)">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server"
    Text
    ='<%# Bind("RealDiscountRate") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server"
    Text
    ='<%# Bind("RealDiscountRate", "{0:0.0%}") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>


    </Columns>
    </asp:GridView>

    上面是百分比的格式!

    实例:

    DataFormatString="{0:0.00%}" 或 DataFormatString="{0:p}"  绑定:0.833333..... 输出 83.33%

    DataFormatString="{0:0.0%}" 绑定:0.833333..... 输出 83.3%

    DataFormatString="{0:0.%}" 绑定:0.833333..... 输出 83%



    和这个

    <%#String.Format("{0:0.0%} ", Eval("RealDiscountRate"))%>有些相似!

    日期格式:

    DataFormatString="{0:f}"   绑定:2012-3-29 10:41:39  输出:2012年3月29日 10:41

    DataFormatString="{0:g}"  绑定:2012-3-29 10:41:39  输出:2012-3-29 10:41

    DataFormatString="{0:G}"  绑定:2012-3-29 10:41:39  输出:2012-3-29 10:41:39

    DataFormatString="{0:d}"  绑定:2012-3-29 10:41:39  输出:2012-3-29

    DataFormatString="{0:D}"  绑定:2012-3-29 10:41:39  输出:2012年3月29日

    DataFormatString="{0:s}"  绑定:2012-3-29 10:41:39  输出:2012-03-29T10:41:39

    DataFormatString="{0:M}"  绑定:2012-3-29 10:41:39  输出:3月29日

    货币格式:货币的格式取决于当前Thread中Culture的设置 (这个不太清楚)

    DataFormatString="{0:c}"  绑定:100 输出:¥100.00

    自定义格式:

    DataFormatString="{0:#,##0}" 绑定:1000000或100000或1000 或0或100   输出:1,000,000或100,000或1,000或0或100

    DataFormatString="{0:#,##}" 绑定:1000000或100000或1000 或0或100   输出:1,000,000或100,000或1,000或空值或100

    DataFormatString="{0:0.##}"  绑定:45.09999999 输出:45.09

  • 相关阅读:
    业务颗粒化思考
    BurpSuite 扩展开发[1]-API与HelloWold
    struts2和velocity整合问题
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/fuge/p/2423360.html
Copyright © 2011-2022 走看看