Solved

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

Posted on 2007-11-20
7
3,257 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:AXISHK
  • 4
  • 3
7 Comments
 
LVL 3

Expert Comment

by:john_steed
ID: 20326073
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
0
 

Author Comment

by:AXISHK
ID: 20326137
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.
0
 
LVL 3

Expert Comment

by:john_steed
ID: 20326161
It should use your regional settings in Windows. Try with the code above to see if it goes to dollar when using Format
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:AXISHK
ID: 20326271
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
0
 
LVL 3

Expert Comment

by:john_steed
ID: 20326287
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
0
 

Author Comment

by:AXISHK
ID: 20326345
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 ??
0
 
LVL 3

Accepted Solution

by:
john_steed earned 500 total points
ID: 20326362
I'm not sure about that, maybe you can change it in the registry.
Also take a look at your machine.config file, located in your .net framework installation directory to see if it has a cultureinfo parameter.

You might also change it for the entire site by putting this in your web.config
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" />
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question