What is the proper data annotation to format my decimal property?
46,927
[DisplayFormat(DataFormatString="{0:#.####}")]
See Custom Format Strings for formats and DisplayFormatAttribute
for examples
Author by
Bill Greer
BY DAY: ASP.NET, IoT, C# Software Developer for MMI. BY NIGHT: I' a developer. I code day and night. FOR FUN: Fishing, tennis, hiking and coding.
Updated on August 01, 2022Comments
-
Bill Greer over 1 year
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;}