Link to home
Start Free TrialLog in
Avatar of danielivanov2
danielivanov2Flag for Romania

asked on

problem with dropdownlist values when using globalization

I have an web application, C#, .Net 2.0. I use globalization in web.config, in order to display all currency values in Euro format. But the values retrieved when selecting from any dropdownlist are multiplied with 100 (data stored in xml file).
In code attached, when selecting 0.010 value, the actual value in debug node is "1". If removing "globalization" tag, it correctly renders "0.01"
How should I resolve this? I don't need this particular culture="de-DE", any culture that provides "Euro" format would be ok.
Thanks
web.config:
<globalization culture="de-DE" uiCulture="de-DE" requestEncoding="utf-8" responseEncoding="utf-8" />

xml sample: 
<TarifGrup id="0.000" value="0.000"></TarifGrup>
<TarifGrup id="0.005" value="0.005"></TarifGrup>
<TarifGrup id="0.010" value="0.010"></TarifGrup>
<TarifGrup id="0.015" value="0.015"></TarifGrup>

aspx:
<asp:XmlDataSource ID="XmlDataSourceCustomOffer" DataFile="~/App_Data/CustomOffer.xml" runat="server"></asp:XmlDataSource>
<asp:DropDownList ID="DropDownListTarifGrup" runat="server" 
                                    AutoPostBack="false" Width="70" DataTextField="id" DataValueField="value">
                                </asp:DropDownList>
aspx.cs:
XmlDataSourceCustomOffer.XPath = "Elements/Tarife/TarifGrup";
            DropDownListTarifGrup.DataSource = XmlDataSourceCustomOffer;
            DropDownListTarifGrup.DataBind();

decimal rateOnnet=Convert.ToDecimal(DropDownListTarifGrup.SelectedValue);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of joriszwaenepoel
joriszwaenepoel
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danielivanov2

ASKER

It works! But please one more info: I don't want to use ",", we in Romania are used with "." What culture should I use? Many thanks
I don't know if there is an existing culture with "EURO" as currency that has "." as decimal symbol.  You could try all of them, but when working with cultureinfo in code, you can modify these settings individually, like in the following example:

        Dim ci As New Globalization.CultureInfo("de-DE")
        ci.NumberFormat.CurrencyDecimalSeparator = "."
        ci.NumberFormat.CurrencyGroupSeparator = ","


Ok. Meanwhile I have found the needed culture (en-IE)(https://www.experts-exchange.com/questions/22077641/EURO-currency-symbol-with-decimal-point-instead-of-a-comma.html), available across entire application. Thanks!