I have one view page (MyView.aspx) and many data sources to bind on this page.
Lets say it has Books, Publishers, Comments, etc.
Each one of those has an object which provides a List, List, etc.
In my view, what are my optiosn for multilple model biding?
I want to check to see if each one is empty, and then enumerate it. But I can’t check Model.Count() because wouldn’t Model be made of all those objects if I set the page to inheriet from ?
What are my options? Should I load each content area in a control/partial view?
Or can I just dump each object into ViewData and then check the count by casting in the view?
Thanks so much for taking a look at my problem.
Have you considered using a ViewModel that contains all Lists of all of your different data fields and using that to populate your View?
Example:
ViewModel:
Then in your View you could simply check if a specific field was null prior to enumerating through it:
View: