Closed philanderson888 closed 4 years ago
At the moment here is the code in the model
[Display(Name = "Date")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime LogDate { get; set; }
I'm not sure if I have to update the model code or the view code.
Let's try updating the model code first
Let's try this fix
DataFormatString = "{0:yyyy-MM-dd}"
public class ObScore
{
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; }
}
and
<div class="form-group">
@Html.LabelFor(model => model.Date, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@* Control with date picker *@
@Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })
</div>
</div>
And - yes - wow - just making that very small change has worked!
Problem is now fixed!!!
Should update Notion now also!
At the moment the date is blank in edit mode even though there is a valid date in the database.
Change the view logic to show the date
Should be trivial.