I'm trying to use the EditorFor in MVC 5 to display a numeric value with commas, if the number is over 999. Here's my code:
The viewmodel:
[DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = false)]
public decimal Amount { get; set; }
The template:
@Html.EditorFor(modelItem => Model.Rows[i].CostItem.Amount, new { @id = "CostAmt_" + i, @name = "monthCost" })
and then the custom template:
@model decimal
@Html.TextBox("", (Model),
new { @class = "monthCost form-control" })
10,000.00 shows up fine if I use DisplayFor but EditorFor displays 10000.00 in the textbox. What am I missing here?