PC Review


Reply
Thread Tools Rate Thread

Currency Symbols

 
 
David C
Guest
Posts: n/a
 
      9th Oct 2009
I have a need to display amounts from an import file in a GridView column
with different currency symbols based on what country the amount is from. I
looked at the formatting but could not figure out how to do this. It would
be nice to simply set the currency symbol in RowDataBound event. Can anyone
help with this? Thanks.

David


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      9th Oct 2009
On Oct 9, 2:32*pm, "David C" <dlch...@lifetimeinc.com> wrote:
> I have a need to display amounts from an import file in a GridView column
> with different currency symbols based on what country the amount is from.*I
> looked at the formatting but could not figure out how to do this. It would
> be nice to simply set the currency symbol in RowDataBound event. *Can anyone
> help with this? *Thanks.
>
> David


You can easily do this if you know the culture name. For example, en-
US for US, sv-SE for Sweden...

Then

double v = 1234.567d;
System.Globalization.CultureInfo c = new
System.Globalization.CultureInfo("sv-SE");
Response.Write(v.ToString("C", c));

would give you a string with a currency symbol.

 
Reply With Quote
 
David C
Guest
Posts: n/a
 
      9th Oct 2009

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:38191b83-09cf-4ddc-9452-(E-Mail Removed)...
On Oct 9, 2:32 pm, "David C" <dlch...@lifetimeinc.com> wrote:
> I have a need to display amounts from an import file in a GridView column
> with different currency symbols based on what country the amount is from.
> I
> looked at the formatting but could not figure out how to do this. It would
> be nice to simply set the currency symbol in RowDataBound event. Can
> anyone
> help with this? Thanks.
>
> David


You can easily do this if you know the culture name. For example, en-
US for US, sv-SE for Sweden...

Then

double v = 1234.567d;
System.Globalization.CultureInfo c = new
System.Globalization.CultureInfo("sv-SE");
Response.Write(v.ToString("C", c));

would give you a string with a currency symbol.

Thank you both. It worked like a charm!

David


 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      9th Oct 2009
"David C" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I have a need to display amounts from an import file in a GridView
> column with different currency symbols based on what country the
> amount is from. I looked at the formatting but could not figure out
> how to do this. It would be nice to simply set the currency symbol in
> RowDataBound event. Can anyone help with this? Thanks.


Everyone is leading you to globalization/localization, which is fine if
the issue is displaying in the user's currency. You simply output
ToString("C") and make sure you have the web app set to respect the
currency of the user's settings. This does not sound like your issue,
but if it is, there are plenty of sites showing how to set currency to
the user's specifics. Converting to the currency requires knowing the
conversion rates.

It sounds like you mean the actual transaction was in a certain
currency, which is a slight different issue. In this case, you can still
use ToString("C"), but you will have to set the culture of the thread
programatically to get er done. And you will want to set the culture of
the worker thread for the request back to the normal culture after you
do this.

The other option is to set up your own library to return the currency
with the correct symbol or look for a third party library.

Of the options, temporarily flipping the thread to the culture of the
currency and then back will be the least amount of work up front. To
make this easiest, you need a culture lookup (table if it were me) that
can link to whatever indicator you use in the database to identify the
currency or country of the transaction.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      9th Oct 2009
"Mark Rae [MVP]" <(E-Mail Removed)> wrote in news:Oe62$8NSKHA.3540
@TK2MSFTNGP04.phx.gbl:

> http://tinyurl.com/yj2hrkq


I love the "let me google that for you", but I think the OP needs advice
on setting individual rows based on the country the transaction was
from, not the country of the user. Same advice, if you are willing to
flip the thread and then flip back on binding complete, but it is a
different problem domain from "why are my user's in Mexico not seeing
pesos".

peace and grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
David C
Guest
Posts: n/a
 
      9th Oct 2009

"Gregory A. Beamer" <(E-Mail Removed)> wrote in message
news:Xns9C9F62B954939gbworld@207.46.248.16...
> "David C" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
>> I have a need to display amounts from an import file in a GridView
>> column with different currency symbols based on what country the
>> amount is from. I looked at the formatting but could not figure out
>> how to do this. It would be nice to simply set the currency symbol in
>> RowDataBound event. Can anyone help with this? Thanks.

>
> Everyone is leading you to globalization/localization, which is fine if
> the issue is displaying in the user's currency. You simply output
> ToString("C") and make sure you have the web app set to respect the
> currency of the user's settings. This does not sound like your issue,
> but if it is, there are plenty of sites showing how to set currency to
> the user's specifics. Converting to the currency requires knowing the
> conversion rates.
>
> It sounds like you mean the actual transaction was in a certain
> currency, which is a slight different issue. In this case, you can still
> use ToString("C"), but you will have to set the culture of the thread
> programatically to get er done. And you will want to set the culture of
> the worker thread for the request back to the normal culture after you
> do this.
>
> The other option is to set up your own library to return the currency
> with the correct symbol or look for a third party library.
>
> Of the options, temporarily flipping the thread to the culture of the
> currency and then back will be the least amount of work up front. To
> make this easiest, you need a culture lookup (table if it were me) that
> can link to whatever indicator you use in the database to identify the
> currency or country of the transaction.
>
> Peace and Grace,
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> Twitter: @gbworld
> Blog: http://gregorybeamer.spaces.live.com
>
> *******************************************
> | Think outside the box! |
> *******************************************


We are actually getting a feed from a separate system. That system has an
amount field (CSV file) and will also have a "Currency Code" for us to
display (have not seen it yet) and I am guessing it to have codes like "US",
"FR", "CA", etc. Our users want to see the representation of that amount
using appropriate currency symbols. We do not need to convert anything,
e.g. dollars to franks, etc., just show the symbol. Then we need to toal by
each "Currency Code".

Thus, your solution is fine.

David


 
Reply With Quote
 
David C
Guest
Posts: n/a
 
      9th Oct 2009

"Gregory A. Beamer" <(E-Mail Removed)> wrote in message
news:Xns9C9F62B954939gbworld@207.46.248.16...
> "David C" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
>> I have a need to display amounts from an import file in a GridView
>> column with different currency symbols based on what country the
>> amount is from. I looked at the formatting but could not figure out
>> how to do this. It would be nice to simply set the currency symbol in
>> RowDataBound event. Can anyone help with this? Thanks.

>
> Everyone is leading you to globalization/localization, which is fine if
> the issue is displaying in the user's currency. You simply output
> ToString("C") and make sure you have the web app set to respect the
> currency of the user's settings. This does not sound like your issue,
> but if it is, there are plenty of sites showing how to set currency to
> the user's specifics. Converting to the currency requires knowing the
> conversion rates.
>
> It sounds like you mean the actual transaction was in a certain
> currency, which is a slight different issue. In this case, you can still
> use ToString("C"), but you will have to set the culture of the thread
> programatically to get er done. And you will want to set the culture of
> the worker thread for the request back to the normal culture after you
> do this.
>
> The other option is to set up your own library to return the currency
> with the correct symbol or look for a third party library.
>
> Of the options, temporarily flipping the thread to the culture of the
> currency and then back will be the least amount of work up front. To
> make this easiest, you need a culture lookup (table if it were me) that
> can link to whatever indicator you use in the database to identify the
> currency or country of the transaction.
>
> Peace and Grace,
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> Twitter: @gbworld
> Blog: http://gregorybeamer.spaces.live.com
>
> *******************************************
> | Think outside the box! |
> *******************************************


p.s. I would put the codes in a table also.


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      10th Oct 2009
On Oct 10, 12:19*am, "David C" <dlch...@lifetimeinc.com> wrote:
> p.s. I would put the codes in a table also.- Hide quoted text -
>


If your application is used for many countries, it really does make
sense. There are few cases when some countries officially use more
than one currency, or changing local currency from one to another
(e.g. in Europe, new countries such as Estonia and Lithuania would get
EUR in 2010). Keeping currency in the database would answer all
questions and makes your life easier ;-)

 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      12th Oct 2009
"David C" <(E-Mail Removed)> wrote in
news:#(E-Mail Removed):

> We are actually getting a feed from a separate system. That system
> has an amount field (CSV file) and will also have a "Currency Code"
> for us to display (have not seen it yet) and I am guessing it to have
> codes like "US", "FR", "CA", etc. Our users want to see the
> representation of that amount using appropriate currency symbols. We
> do not need to convert anything, e.g. dollars to franks, etc., just
> show the symbol. Then we need to toal by each "Currency Code".
>
> Thus, your solution is fine.


The big thing is flipping the thread back if there are additional bits
on the page that need the user's thread. if not, just flip the thread to
other cultures and "print out" as currency.

Good to hear this will work for you.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated currency symbols usiku Microsoft Excel Misc 3 26th May 2006 01:49 PM
Currency Symbols... Shhhh Microsoft Excel Discussion 3 22nd Sep 2005 07:35 PM
allow all currency symbols magister Microsoft ASP .NET 2 3rd Nov 2004 12:05 PM
Displaying different currency symbols Eamon Microsoft Excel Worksheet Functions 2 30th Aug 2004 10:35 PM
Currency Symbols Neil Windows XP Internet Explorer 1 30th Apr 2004 08:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:45 AM.