In my ASP.NET Core 1.1
with EF Core 1.1
, following View
is displaying Cost
value without dollar format. I would like to show it as, say, $1,945.25
. Question: What I may be missing? Note: I tried this and this SO Posts
but still the same issue.
Model:
public class costs
{
....
....
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:c}")]
public float? Costs { get; set; }
....
....
}
TestViewModel:
public class TestViewModel
{
....
....
public string ProdName{ get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:c}")]
public float? Costs { get; set; }
....
....
}
View:
@model myProj.Models.TestVewModel
....
....
<td>@Html.DisplayFor(t =>t.Cost)</td>
<td>@Html.EditorFor(t =>t.Cost)</td>
....
....
UPDATE:
The only difference I can think of between this post and this one may be that I'm using SQL Server 2012 that has data type real
for costs
column. But, I'm not sure if that is a reason for the issue. The real
datatype was created via EF-Core migration
commands.