Currency formatting in DataList

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?
PrimeNYAsked:
Who is Participating?
 
the_bachelorCommented:
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
 
the_bachelorCommented:
Try
Eval("BusPrice", "${0:#,###}")
0
 
PrimeNYAuthor Commented:
the bachelor - Thanks but I've tried that and other similar versions and nothing seems to be recognized.
0
 
the_bachelorCommented:
As an altenative you could try:
Text='<%# String.Format("{0:$#,###}",Eval("BusPrice"))
0
 
PrimeNYAuthor Commented:
Got it.  Problem was with the data type in the table.  Had it as VarChar instead of Money.  Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.