【发布时间】:2011-07-18 15:02:15
【问题描述】:
我想知道如何将强类型视图价格字段转换为 2 位说明符,就像我的数据库中有一个货币字段,例如将 15 转换为 15.0000,我想在视图中显示 15.00,下面是代码:
<%: Html.TextBoxFor(model =>model.Price, new { maxlength = "5", style = "width:40px;" })%>
我尝试了类似但没有成功的方法:
<%: Html.TextBoxFor(model => String.Format("{0:n}"model.Price), new { maxlength = "5", style = "width:40px;" })%>
【问题讨论】:
-
已经回答 [这里][1] :)。 [1]:stackoverflow.com/questions/3758573/…
标签: c# asp.net-mvc asp.net-mvc-2 string-formatting strongly-typed-view