Solved

problem with dropdownlist values when using globalization

Posted on 2010-11-28
4
651 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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