format varchar to currency in datalist


I am trying to format a varchar (using MS SQL Server) to display as a currency in a datalist in VS. This is my code and phone_amount is what needs to be displayed as a currency:

                              <tr bgcolor="WhiteSmoke">
                                    <TD align="left"><FONT face="Verdana" size="1"><%#container.dataitem("phone_year")%></FONT></TD>
                                    <TD align="left"><FONT face="Verdana" size="1"><%#container.dataitem("phone_month")%></FONT></TD>
                                    <TD align="left"><FONT face="Verdana" size="1"><%#container.dataitem("Employee")%></FONT></TD>
                                    <TD align="left"><FONT size="1" face="Verdana"><%#container.dataitem("PhoneNumber")%></FONT></TD>
                                    <td align="left"><FONT face="Verdana" size="1"><%#container.dataitem("FunctionalAccount")%></FONT></td>
                                    <td align="left"><FONT face="Verdana" size="1"><%#container.dataitem("phone_amount")%></FONT></td>
                                    <td align="left"><FONT face="Verdana" size="1"><%#container.dataitem("web_verified")%><%#container.dataitem("web_who")%></FONT></td>
                                    <td align="left"><FONT face="Verdana" size="1">[<a href='AlltelVerify.aspx?id=<%#container.dataitem("id")%>&s=1'>Verify</a>]&nbsp;&nbsp;&nbsp;[<a href='AlltelRemove.aspx?id=<%#container.dataitem("id")%>&s=1'>Remove</a>]&nbsp;&nbsp;&nbsp;[<a href='Amount.aspx?id=<%#container.dataitem("id")%>&s=1'>Amount</a>]</FONT></td>

I think I need to format as a double, but I'm not sure how to do that. If you could help me I would really appreciate it.
Who is Participating?
DotNetThinkerConnect With a Mentor Commented:
try this...

<%# String.Format("{0:c}", container.dataitem("phone_amount").ToString()) %>
Bob LearnedCommented:
If you data is numeric, then you can use ToString("c").  If it is string, then you need to convert to double, and then use ToString("c").

Perhaps you can perform the layout in the sql-script.
Something like this: CONVERT(varchar, CONVERT(money, YourFieldName), 1)
savache27Author Commented:

That worked :) Thanks for the help!
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.