Formatting int to currency-formatted string in aspx page
asp.net
Solution
Try this code:
<asp:Label ID="savings" runat="server" Text='<%# string.Format("{0:C}", Eval("savings"))%>' />
Problem
Suppose I have this label in my aspx page: ``` <asp:Label ID="savings" runat="server" Text='<%# Eval("savings")%>' /> ``` Is there a way to format the text of a label as a currency-formatted string? I'm looking for something like this: ``` <asp:Label ID="savings" runat="server" Text='<%# Eval("savings").ToString("C")%>' /> ``` When I run this I get the: ``` No overload for method 'ToString' takes 1 arguments ``` compilation error. I know I can easily do this in my code-behind but I want to know if it's possible from the .aspx document.