HTML.EditorFor with 3 decimal places

邮差的信 提交于 2019-12-12 10:34:37

问题


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

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


回答1:


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

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


来源:https://stackoverflow.com/questions/16232653/html-editorfor-with-3-decimal-places

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!