我想知道如何将强类型视图价格字段转换为 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;" })%>