views:

178

answers:

1

Hi all;

<asp:GridView ID="Grd" runat="server">
    <column>

    <asp:TemplateField HeaderText="Number">
                            <ItemTemplate>
                                <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

A: 

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;
Andrew Bezzub
How to make specific format ?
Oraclee
Not Work Andrew, How to make in-line specific format ? "{0:N0}" ?
Oraclee
What about using smth like "#,#.###" instead of "{0:N0}"?
Andrew Bezzub
Btw, there is also ThreadUICulture that can also be overriden.
Andrew Bezzub
Andrew not work Text='<%# Eval("Number","{0:#.#,###}") %>'> please help output "12345" No separator
Oraclee
I meant trying Text='<%# Eval("Number","#.#,###") %>'>
Andrew Bezzub