I am trying to display a datetime field retrieved froma database in my razor file with the following:
@Html.EditorFor(model => model.RequestDate);
I know with 100% certainty the RequestDate is not null, as I examined the model that was passed in the view, and it was the date from the database. However, the datetime textbox still displays "mm/dd/yyyy". I don't know why it is not display the date. Any ideas? Thank you.
Here is my model:
[Display(Name = "Time")]
[DataType(DataType.Date)]
public DateTime RequestDate { get; set; }
EDIT:
[HttpGet]
public ActionResult DispatchResponseIndex()
{
DispatchResponseModel model = new DispatchResponseModel();
//if the users session id isnt null then we know they have data related to this form
object UserID = Session["TestID"];
if (UserID == null)
{
return View(model); //default view
}
else
{
UserID = Session["TestID"];
}
LoadDB(model, (Guid)UserID);
//looking at the model here the RequestDate has a valid date of //{5/24/2013 12:00:00 AM}
return View(model);
}
EDIT 2:
If I use @Html.TextBox("asdasd",Model.RequestDate); Then it will display the saved date in string format, but I need to use the built in date editor for the text box.