Is there some way to use the DataType annotation on a list (IEnumerable) of objects, so that when I use DisplayFor in my template it will format the date correctly?
model:
public class CallOverview
{
[DataType(DataType.Date), DisplayFormat(DataFormatString = @"{0:dddd dd MMMM yyyy}")]
public IEnumerable<DateTime> Days { get; set; }
}
view:
@foreach (var day in Model.Days)
{
<p>@Html.DisplayFor(modelItem => day)</p>
}
output:
31/07/2012 00:00:00