Link to home
Start Free TrialLog in
Avatar of savache27
savache27

asked on

format varchar to currency in datalist

Hi,

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:

<ItemTemplate>
                              <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>
                              </tr>
                        </ItemTemplate>

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.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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").

Bob
Perhaps you can perform the layout in the sql-script.
Something like this: CONVERT(varchar, CONVERT(money, YourFieldName), 1)
ASKER CERTIFIED SOLUTION
Avatar of DotNetThinker
DotNetThinker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of savache27
savache27

ASKER

DotNetThinker:

That worked :) Thanks for the help!