danielivanov2
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
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);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.CurrencyDe cimalSepar ator = "."
ci.NumberFormat.CurrencyGr oupSeparat or = ","
Dim ci As New Globalization.CultureInfo(
ci.NumberFormat.CurrencyDe
ci.NumberFormat.CurrencyGr
ASKER
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!
ASKER