{0:c} format in Gridview column to show $ regardless of browser country?

M

Mark B

I want some numbers shown in a GridView column to show as e.g. $5,423.98
even if the end user is in a foreign country which doesn't use dollars.

What would I put in place of {0:c}?
 
P

psycho

I want some numbers shown in a GridView column to show as e.g. $5,423.98
even if the end user is in a foreign country which doesn't use dollars.

What would I put in place of {0:c}?

I think that will make use of server's culture and not user browser's
culture
 
G

Guest

I want some numbers shown in a GridView column to show as e.g. $5,423.98
even if the end user is in a foreign country which doesn't use dollars.

What would I put in place of {0:c}?

Hi Mark

you would simply need to specify a value of culture attribute.

Either use the web.config file to set it globally

<globalization uiCulture="en" culture="en-GB" /> // e.g. to show £

or set the Culture and UICulture attributes of the @ Page directive

<%@ Page UICulture="en" Culture="es-GB" %>

http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
http://msdn2.microsoft.com/en-us/library/system.globalization.regioninfo.aspx

Hope this helps
 
M

Mark B

Do you agree with:

"I think that will make use of server's culture and not user browser's
culture"?


I want some numbers shown in a GridView column to show as e.g. $5,423.98
even if the end user is in a foreign country which doesn't use dollars.

What would I put in place of {0:c}?

Hi Mark

you would simply need to specify a value of culture attribute.

Either use the web.config file to set it globally

<globalization uiCulture="en" culture="en-GB" /> // e.g. to show £

or set the Culture and UICulture attributes of the @ Page directive

<%@ Page UICulture="en" Culture="es-GB" %>

http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
http://msdn2.microsoft.com/en-us/library/system.globalization.regioninfo.aspx

Hope this helps
 
G

Guest

Do you agree with:

"I think that will make use of server's culture and not user browser's
culture"?

Mark, the GridView format is based on the current culture and to show
it in USD to all users you have to set culture in "en-US". Currency
format cannot be based just on the browser culture only, because it
makes no sense as $5,423 not equals to £5,423, or 5,423 €. In this
case you need to use an exchange rate to recalculate the value. If you
need to have multiple currencies based on the browser settings check
this tutorial at http://quickstarts.asp.net/quickstartv20/aspnet/doc/localization/culture.aspx.
Hope this helps
 
M

Mark B

Yes but we'll need other parts in the GridView, e.g. DateTime values to be
in the correct format for the end user (e.g. French, Chinese, Arabic). The
only thing we want to override is the Amount column which is in USD.


Do you agree with:

"I think that will make use of server's culture and not user browser's
culture"?

Mark, the GridView format is based on the current culture and to show
it in USD to all users you have to set culture in "en-US". Currency
format cannot be based just on the browser culture only, because it
makes no sense as $5,423 not equals to £5,423, or 5,423 €. In this
case you need to use an exchange rate to recalculate the value. If you
need to have multiple currencies based on the browser settings check
this tutorial at
http://quickstarts.asp.net/quickstartv20/aspnet/doc/localization/culture.aspx.
Hope this helps
 
G

Guest

Yes but we'll need other parts in the GridView, e.g. DateTime values to be
in the correct format for the end user (e.g. French, Chinese, Arabic). The
only thing we want to override is the Amount column which is in USD.

Ah, but this is very simple. You don't need to use the formatting by
culture in this case and instead of "{0:c}" - which is currency
format, use "${0:n}" where $ - is your preferred currency symbol and n
- is for numeric. Note, that this would convert

$5,423.98 for US and others who has "." as a decimal delimiter
$5.423,98 for Europe and others who has "," as decimal delimiter
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top