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,