[Solved] Datetime field in MVC Entity Framework


DateTime picker can be implemented using jQuery’s date time picker. Or if you want an inbuilt MVC datetime picker, modify your code as :

Field:

   [DataType(DataType.Date)]
   public DateTime EnrollmentDate { get; set; }  

and then in view

  <div class="form-group">
            @Html.LabelFor(model => model.EnrollmentDate , htmlAttributes: new {@class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.EnrollmentDate , new {htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.EnrollmentDate , "", new { @class = "text-danger" })
            </div>
        </div>

which will then render the date picker for you.

1

solved Datetime field in MVC Entity Framework