有3位小数HTML.EditorFor [英] HTML.EditorFor with 3 decimal places

查看:619
本文介绍了有3位小数HTML.EditorFor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何与3位小数显示模型小数领域。目前它,它缩短了2位数

How to display the model decimal field with 3 decimal places. Currently it shortens it to 2 digits.

1237现在将显示为1.24;)

1,237 currently will be displayed as 1,24 ;)

推荐答案

您可以在您的视图模型使用数据注释,如下所示:

You can use Data Annotations on your View Model, like this:

[DisplayFormat(DataFormatString = "{0:0.00}", ApplyFormatInEditMode = true)]
public decimal Num { get; set; }

这篇关于有3位小数HTML.EditorFor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆