Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

How does the currency symbol displayed in ASP using DataFormatString="{0:c}"

Have any idea how the currency symbol is displayed in ASP.NET using DataFormatString="{0:c}".
I try to run a sample program on a local SQL 2005 Express and the currency is displayed as UK pound sign. I want to change it to "$" sign but couldn't where should I configure it ?

Thank
Avatar of john_steed
john_steed

Hi,

To set the currency in .net, we can set the globalication's culture info
of the current Context via
System.Thread.CurrentThread.CurrentCulture or
System.Thread.CurrentThread.CurrentUICulture
the former is for date and currency's localization formatting
and the latter is for UI's localization

This should probably do the trick :

private void Page_Load(object sender, System.EventArgs e)
{
System.Threading.Thread.CurrentThread.CurrentCultu re = new System.Globalization.CultureInfo("en-US");
decimal dec = 4343.34343434M;
Response.Write( String.Format("{0:c}",dec));

}

hope this helps
Avatar of AXISHK

ASKER

Thanks but how will it be displayed in ASP using DataFormatString="{0:c}" by default. Will it follow the regional currecny setting in Window, or in  SQL server database / tables (where) ?? I take a look for the Regional setting in Window and my currency is set to HK$. However, the ASP display UK dollar ....

Thanks.
It should use your regional settings in Windows. Try with the code above to see if it goes to dollar when using Format
Avatar of AXISHK

ASKER

Yes, it could display as $ sign right now.

But I still want to know which settings cause all my ASP currency sign  to display a UK pound sign. Window Regional Settings currency is already set to HK$. Hence, I could easily customize the right currency by setting the Window (or SQL or IIS) without need to put any coding on the ASP page.

Thanks
Hey,

It uses the currency of the user that views the website, or depending on impersonation the local machine account.

I found this :

Unless you specifically impersonate some user, the impersonating user
is the same as the authenticating user. In addition, the logged-on user
refers to the person who is logged on to the server,
-------------------------------------------------

In IIS, by default, the authenticating user is the IUSR_MachineName account
(known in some OSs as the Internet Guest Account). When this account is
created, it is created with the default regional settings
Avatar of AXISHK

ASKER

Thanks.
The autenticating user is ASPNET on my XP. So, does it mean I couldn't change the  regional setting for this account without uninstall / install the ASP.NET again ??
ASKER CERTIFIED SOLUTION
Avatar of john_steed
john_steed

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial