[英]Format money to currency in asp.net mvc c#
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 :
它的数据类型是money,我想将其格式化为:8.20、10.00和100,00.00,这是我的代码:
$<%: string.Format("{0:00.00}", price)%>
But the output is not like what I want, anyone have any idea about that? 但是输出与我想要的不一样,有人对此有任何想法吗? Thanks.
谢谢。
尝试使用货币格式( 0:C
):
<%: string.Format("{0:C}", price) %>
I think you are looking for: 我认为您正在寻找:
$<%: string.Format("{0:#0.00}", price)%>
This will skip the leading 0 for numbers under 10. 对于10以下的数字,这将跳过前导0。
See the MSDN page for more information. 有关更多信息,请参见MSDN页面 。
尝试这个:
<%: string.Format("{0:N2}", price) %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.