German UI Culture de-DE decimal changing to comma value issue in asp.net

asp.net, c#

Solution

you can change number format info as per below code

Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";

try below code for parsing the decimal values as per culture.

string str = "50,3";
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
double d = double.Parse(str, Thread.CurrentThread.CurrentCulture.NumberFormat);

it gives result d = 50.3

Problem

I am using german UI Culture in my asp.net application. I am changing my application's UI culture based on the language selected in the dropdown, on dropdown selected index change i am using this code ``` Thread.CurrentThread.CurrentCulture = new CultureInfo(this.lstLanguage.SelectedValue); Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.lstLanguage.SelectedValue); ``` the Dropdown is as below ``` <asp:DropDownList cssClass="ddllanguage" ValidationGroup="b" runat="server" ID="lstLanguage" AutoPostBack="True" OnSelectedIndexChanged="LstLanguage_SelectedIndexChanged" meta:resourcekey="lstLanguage"> <asp:ListItem Value="en-US" Text="English" meta:resourcekey="ListItemResource2" ></asp:ListItem> <asp:ListItem Value="de-DE" Text="Deutsch" meta:resourcekey="ListItemResource3"></asp:ListItem> </asp:DropDownList> ``` My problem is after changing the language to de-DE all the decimal values in my application are being changed as comma, all the decimal number like 5.12 is coming as 5,12 all the decimal values are changed to comma. How to get decimal values as it is without comma.

Original source

Related problems