Solved

problem with dropdownlist values when using globalization

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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