I'm trying to display the contents of a collection, in my View .. but using a DisplayTemplate
to handle the definition of the view, for that specialized property/object.
eg.
<div class="display-label">Foos</div>
<div class="display-field">@Html.DisplayTextFor(_ => Model.Foos)</div>
and the foo object is..
public class Foo
{
public string Name { get; set; }
public string Blah { get; set; }
}
and...
public string MyModel
{
public ICollection<Foo> Foos { get; set;}
}
So i created a folder called DisplayTemplates
, in my View folder for this Controller.
I then added in a file called Foo.cshtml
with the following content
@model MyNamespace.....Foo
@Model [@Model.Blah] @Model.Name
and what i have getting displayed on my view?
System.Collections.Generic.List`1[MyNamespace.....Foo]
. I've confirmed that there is at least one item in this collection. Any ideas, folks?