I'm building an intranet and the home page is covered in widgets that show lots of different bits of data. I have a Home.cs model with various IEnumerables properties for the data required. I have been using View folder DisplayFor templates to render that data. I now come to a problem where two different lists of Staff need to be shown in two different ways.
I could use a partial view to render one of the lists or perhaps inherit the class and have a different template. Inheritance seems more work that necessary, I was wondering if anyone knows of a specific way MVC was designed to use or perhaps just a prefered solution by anyone?
Just have two different templates, then specify the template to use for each using this overload of DisplayFor
:
@Html.DisplayFor(m => m.StaffList, "StaffTemplate1")
@Html.DisplayFor(m => m.StaffList, "StaffTemplate2")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With