Solved

problem with dropdownlist values when using globalization

Posted on 2010-11-28
4
644 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now