I have a model property that is declared as type List
.
public class MyModel
{
List MyProperty { get; set; }
}
You could use the [UIHint]
attribute:
public class MyModel
{
[UIHint("TemplateForTheList")]
public List<MyClass> MyProperty { get; set; }
}
or specify the template name as second parameter to the DisplayFor
helper:
@model MyModel
@Html.DisplayFor(m => m.MyProperty, "TemplateForTheList")
and then have a TemplateForTheList.cshtml
template:
@model List<MyClass>
...
In this case the templating engine will not render the template for each element of the collection property. It will simply pass the collection itself to the template.