Currency Symbols

Discussion in 'ASP .Net' started by David C, Oct 9, 2009.

  1. David C

    David C Guest

    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
     
    David C, Oct 9, 2009
    #1
    1. Advertising

  2. On Oct 9, 2:32 pm, "David C" <> 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.
     
    Alexey Smirnov, Oct 9, 2009
    #2
    1. Advertising

  3. David C

    David C Guest

    "Alexey Smirnov" <> wrote in message
    news:...
    On Oct 9, 2:32 pm, "David C" <> 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
     
    David C, Oct 9, 2009
    #3
  4. "David C" <> wrote in
    news::

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 9, 2009
    #4
  5. "Mark Rae [MVP]" <> 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 9, 2009
    #5
  6. David C

    David C Guest

    "Gregory A. Beamer" <> wrote in message
    news:Xns9C9F62B954939gbworld@207.46.248.16...
    > "David C" <> wrote in
    > news::
    >
    >> 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
     
    David C, Oct 9, 2009
    #6
  7. David C

    David C Guest

    "Gregory A. Beamer" <> wrote in message
    news:Xns9C9F62B954939gbworld@207.46.248.16...
    > "David C" <> wrote in
    > news::
    >
    >> 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.
     
    David C, Oct 9, 2009
    #7
  8. On Oct 10, 12:19 am, "David C" <> 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 ;-)
     
    Alexey Smirnov, Oct 10, 2009
    #8
  9. "David C" <> wrote in
    news:#:

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 12, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark

    RangeValidator with currency

    Mark, Jul 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,634
    David Waz...
    Jul 11, 2003
  2. Peter Blum

    Re: allow all currency symbols

    Peter Blum, Oct 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    471
    magister
    Nov 3, 2004
  3. JPike

    Currency Symbols in tooltip

    JPike, Nov 11, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    126
    JPike
    Nov 15, 2004
  4. J P Singh

    Storing Currency Symbols in Database

    J P Singh, Jan 27, 2004, in forum: ASP General
    Replies:
    4
    Views:
    266
    Aaron Bertrand - MVP
    Jan 27, 2004
  5. James Sturrock

    Displaying currency symbols in select

    James Sturrock, Aug 17, 2007, in forum: Ruby
    Replies:
    6
    Views:
    156
    James Sturrock
    Aug 20, 2007
Loading...

Share This Page