Solved

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

Posted on 2007-11-20
7
3,229 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now