asp.net-mvcentity-frameworkdata-annotationsdisplayformat

MVC Entity Framework Integer Thousand Separator


This is probably a very simple question but i cannot work it out and i cannot find it anywhere.

I have a model with the following property:

[DisplayFormat(DataFormatString ="{0:0.##}")]
public decimal Jan { get; set; }

As you can see, it is a simple decimal value which I have used the DisplayFormat annotation on in order to remove the decimal places, if the decimal places are .00.

However, I now need to edit this DisplayFormat in order to include thousand and million separators as commas.

Does anybody know how i would go about this please?

Many Thanks In Advance,


Solution

  • [DisplayFormat(DataFormatString = "{0:N2}")]
    public decimal Jan { get; set; }