-1

My local machine is Turkish, if i run my asp.net aplication , i can see easly my decimal value from mysql database like below.it is my desire and everything is right what i want. i used "Text='<%#Eval("Veri","{0:N}")%>'". it is working great in my local but if i publish it result below. i want to see ny decimal like :

DB           My LOCAL GridVIEW  My Remote GridView
234567    234.567,00      &nbsp           234,567.00
1234567      1.234.567,00            1,234,567.00


My GridView Code:

  <asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="Veri">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtVeri" runat="server" MaxLength="16" Enabled="false" Text='<%#Eval("Veri","{0:N}")%>' CssClass="form-control input-sm" Style="width: 100%;"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>

This is my db decimal: enter image description here And my awesome result: ( I WANT THIS) enter image description here

ON THE OTHER HAND : if i publish my asp.net application to Customer : ( I DONT WANT THIS)

enter image description here

loki
  • 2,926
  • 8
  • 62
  • 115

2 Answers2

1

With the snippet below you can set the specific number format settings for the page with the GridView on Page_PreInit without changing the whole UI language. This will of course affect all number formats on the page, not just the GridView.

protected void Page_PreInit(object sender, EventArgs e)
    {
        CultureInfo newCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
        NumberFormatInfo numberFormatInfo = (NumberFormatInfo)newCultureInfo.NumberFormat.Clone();
        numberFormatInfo.NumberDecimalSeparator = ",";
        numberFormatInfo.NumberGroupSeparator = ".";
        numberFormatInfo.NumberDecimalDigits = 2;
        newCultureInfo.NumberFormat = numberFormatInfo;
        System.Threading.Thread.CurrentThread.CurrentCulture = newCultureInfo;
    }
VDWWD
  • 35,079
  • 22
  • 62
  • 79
1

You would be better off by setting the culture.

This can be done site-wide in the web.config, using the <globalization uiCulture="tr" culture="tr-TR" /> element, or at the page level in the page directive <%@ Page UICulture="tr" Culture="tr-TR" %>

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
loki
  • 2,926
  • 8
  • 62
  • 115
  • This also works, but this overrides all the culture settings, not just the number formats. If that is no problem then this is indeed easier to implement. – VDWWD Oct 12 '16 at 09:40