?
Solved

Currency formatting in DataList

Posted on 2008-11-12
5
Medium Priority
?
796 Views
Last Modified: 2013-11-26
I have a data bound field in a DataList.  Trying to format it to show currency ($300,000) using the following.
<span style="color: #0000cd">Price:&nbsp;
                                        <asp:Label ID="BusPriceLabel" runat="server" Font-Bold="True" Font-Size="Medium"
                                            Style="font-size: small; position: relative;" Text='<%# Eval("BusPrice", "${0:###,###}") %>' ForeColor="Black"></asp:Label></span></td>

Unfortunately this only produces "$300000".  What am I doing wrong?
0
Comment
Question by:PrimeNY
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:the_bachelor
ID: 22941699
Try
Eval("BusPrice", "${0:#,###}")
0
 

Author Comment

by:PrimeNY
ID: 22941843
the bachelor - Thanks but I've tried that and other similar versions and nothing seems to be recognized.
0
 
LVL 7

Accepted Solution

by:
the_bachelor earned 2000 total points
ID: 22941882
Odd, I tried it and it worked for me.
I'm assuming your using SQL server... What is the data type of your BusPrice column as in the resulset that your passing to the datalist?
Also make sure that you're not experiencing Caching issues with the Browser so when you make changes they are effectively taken into account.
0
 
LVL 7

Expert Comment

by:the_bachelor
ID: 22942009
As an altenative you could try:
Text='<%# String.Format("{0:$#,###}",Eval("BusPrice"))
0
 

Author Comment

by:PrimeNY
ID: 22942093
Got it.  Problem was with the data type in the table.  Had it as VarChar instead of Money.  Thanks for your help.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses

839 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