سؤال

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 ;)

هل كانت مفيدة؟

المحلول

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

[DisplayFormat(DataFormatString = "{0:0.00}", ApplyFormatInEditMode = true)]
public decimal Num { get; set; }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top