What is the proper data annotation to format my decimal property?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 06:36:53

问题


I have a POCO with a decimal property called SizeUS. I would like to use data annotations to format the display of the decimal in a view. My SizeUS property is only displaying 2 decimal places in my view and I want it to display 4 decimal places. What is the proper data annotation to accomplish this ?

[DisplayFormat( ? )]
public decimal SizeUS {get; set;}

回答1:


[DisplayFormat(DataFormatString="{0:#.####}")]

See Custom Format Strings for formats and DisplayFormatAttribute for examples



来源:https://stackoverflow.com/questions/20848969/what-is-the-proper-data-annotation-to-format-my-decimal-property

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