Solved

problem with dropdownlist values when using globalization

Posted on 2010-11-28
4
648 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:danielivanov2
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
joriszwaenepoel earned 400 total points
ID: 34228179
Have you tried replacing the "." with ","?

In the "de-DE" culture, a "," is used as decimal symbol, and a "." as thousand separator (I think).
0
 

Author Comment

by:danielivanov2
ID: 34228188
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
0
 
LVL 10

Expert Comment

by:joriszwaenepoel
ID: 34228223
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 = ","


0
 

Author Closing Comment

by:danielivanov2
ID: 34228227
Ok. Meanwhile I have found the needed culture (en-IE)(http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22077641.html), available across entire application. Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question