简体   繁体   English

HTML.EditorFor有3个小数位

[英]HTML.EditorFor with 3 decimal places

How to display the model decimal field with 3 decimal places. 如何显示带小数点后3位的模型十进制字段。 Currently it shortens it to 2 digits. 目前它将它缩短为2位数。

1,237 currently will be displayed as 1,24 ;) 1,237目前将显示为1,24;)

You can use Data Annotations on your View Model, like this: 您可以在View Model上使用Data Annotations,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM