I have a problem with the DataAnnotation DataType Date, in my view the date is displayed perfectly as I put it in the DataFormatString, but the moment I edit it, it appears as if I had not specified a date before or was not stored in the database, I leave samples.
As seen in the view:
How it looks when I give it Edit
My code is as follows:
[Display(Name = "Fecha de Ingreso")]
[DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "0:yyyy/MM/dd}")]
[DataType(DataType.Date)]
public DateTime fecha_ingreso { get; set; }
Sight code:
<td>
@Html.DisplayFor(modelItem => item.fecha_ingreso)
</td>
//Vista del Edit
<div class="form-group">
@Html.LabelFor(model => model.fecha_ingreso, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.fecha_ingreso, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.fecha_ingreso, "", new { @class = "text-danger" })
</div>
</div>