I'm sure I'm missing something pretty simple here. I've created a custom DateTime display template. This works fine when using:
<%= Html.DisplayFor(x=>x.DateTimeProperty) %>
However, I have a situation where I am iterating over objects in the Model in a for loop while inside a partial control. I want a DateTime property to use the display template, but I can't figure out how to instruct it to do so. The property is a DateTime as it should be. The looks like:
<% foreach (var item in Model) { %>
<%= Html.Encode(item.DateTimeProperty) %>
<% } %>
I can't call Html.DisplayFor(...) because of this structure, but I want all DateTime properties to use my DateTime display template.
I've tried adding a UIHint via DataAnotations, but that doesn't seem to have worked.
How do I do this?