Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-11-20
7
Medium Priority
?
3,308 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

609 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