I have something code like this
@Html.EditorFor(model => model.VoluntaryWork.DateEnded)
@Html.ValidationMessageFor(model => model.VoluntaryWork.DateEnded)
and working fine. But It is retrieving the whole data from my sql
Output from current code
3/22/2017 12:00:00 AM
Desired output
3/22/2017
I try to use a code like this @Html.ValidationMessageFor(model => model.VoluntaryWork.DateEnded.Value.ToShortDateString())
but it gives me an error
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions
I try to search on google and found this but for me its a long method? And I am new in that method so I don't know how to use it.
Is there any shortest way to achieve the desired output?.
Update
Controller code
PersonVoluntaryWork pvw = db.PersonVoluntaryWorks.Single(vw => vw.VoluntaryWorksId == id);
return PartialView("_NewPersonVoluntaryWorks", pvw);
View
@model System.Models.PersonVoluntaryWork
@using (Html.BeginForm())
{
<td>
@Html.EditorFor(model => model.VoluntaryWork.DateEnded)
@Html.ValidationMessageFor(model => model.VoluntaryWork.DateEnded)
</td>
}