0

I have a property for currency:

[DisplayFormat(DataFormatString = "{0:C0}")]
public long Budget { get; set; }

It is displayed in my view like this:

@Model.Budget

How can I display the numbers like this: "10 000 000 000"?

I have tried some different data format strings: {0:# #}, {0:#,#} and {0:N0}, but the numbers are not affected - it just displays as "10000000000".

Solution

The problem was this:

@Model.Budget

It has to be this:

@Html.DisplayFor(model => model.Budget)
Stian
  • 1,522
  • 2
  • 22
  • 52
  • 1
    Does this answer your question? [ASP.Net MVC DisplayFormat](https://stackoverflow.com/questions/2001756/asp-net-mvc-displayformat) DisplayFormat is not affecting `@Model.Budget` you can use .ToString("Format") in your view. – Preben Huybrechts Aug 04 '20 at 05:23
  • @PrebenHuybrechts Absolutely! – Stian Aug 04 '20 at 05:26

0 Answers0