开发者

Asp.Net GridView DataFormatString Problem

开发者 https://www.devze.com 2022-12-23 01:37 出处:网络
<asp:TemplateField HeaderText=\"Number\"> <ItemTemplate> 开发者_Python百科<asp:Label ID=\"LblNbr\" runat=\"server\" Text=\'<%# Eval(\"Number\",\"{0:N0}\") %>\'></asp:Labe

    <asp:TemplateField HeaderText="Number">
                            <ItemTemplate>
                             开发者_Python百科   <asp:Label ID="LblNbr" runat="server" Text='<%# Eval("Number","{0:N0}") %>'></asp:Label>
                            </ItemTemplate>

                        </asp:TemplateField>

    </column>
    </asp:GridView>

Output Format: 3,333,333

I need Output Format: 3.333,333


This is because of the culture you are using. If you need some specific format than use your own culture with NumberFormatInfo (http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx) defined as you need.

You can set use it like this:

        CultureInfo someCulture = new CultureInfo("en-US");
        someCulture.NumberFormat.NumberDecimalSeparator = ",";
        someCulture.NumberFormat.NumberGroupSeparator = ".";
        Thread.CurrentThread.CurrentCulture = someCulture;
0

精彩评论

暂无评论...
验证码 换一张
取 消