Reputation: 2642
I have one field in database, store price of my products. Its datatype is money and I want to format it like : 8.20, 10.00, and 100,00.00 This is my code :
$<%: string.Format("{0:00.00}", price)%>
But the output is not like what I want, anyone have any idea about that? Thanks.
Upvotes: 1
Views: 4345
Reputation: 52538
I think you are looking for:
$<%: string.Format("{0:#0.00}", price)%>
This will skip the leading 0 for numbers under 10.
See the MSDN page for more information.
Upvotes: 0
Reputation: 1039398
Try using the currency format (0:C
):
<%: string.Format("{0:C}", price) %>
Upvotes: 6