开发者

Asp.Net GridView DataFormatString Problem

    <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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜