I m getting this borring error when I try formatting the date using ToString("dd-MM-YYYY") in asp.net mvc 5. Is the a way to do that ? And I dont understand why this error happen
Thanks in advance
My class
public class Registro : Numero
{
public DateTime Date { get; set; }
public decimal Valor { get; set; }
public EnumConducao Conducao { get; set; }
public EnumDestino Destino { get; set; }
}
My view
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Date)
</th>
<th>
@Html.DisplayNameFor(model => model.Valor)
</th>
<th>
@Html.DisplayNameFor(model => model.Conducao)
</th>
<th>
@Html.DisplayNameFor(model => model.Destino)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Date.ToString("dd-MM-YYYY"))
</td>
<td>
@Html.DisplayFor(modelItem => item.Valor)
</td>
<td>
@Html.DisplayFor(modelItem => item.Conducao)
</td>
<td>
@Html.DisplayFor(modelItem => item.Destino)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}
</table>