i have this Model:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime? bday { get; set; }
and it works fine but when i go into edit mode it looks like this, which makes it NULL if i try to save it.
i prefer to keep the Datepicker i want it to get into the format of dd-mm-yyyy. and preferable solved through my viewModel.
View:
<div class="form-group">
@Html.LabelFor(model => model.bday, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.bday, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.bday, "", new { @class = "text-danger" })
</div>
</div>