Solved

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

Posted on 2007-11-20
7
3,268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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