I have been struggling with this problem to no avail. Using MVC4 I have 3 models I wish to show on a single view via partial views. The Single View is comprised of 3 partial views (3 numerated list tables). I can get one model to display in the view, but can't figure out how to display the other 2.
Here is what I have for The View Controller:
[AllowAnonymous]
public ActionResult Dashboard()
{
//Database.SetInitializer<AlertsContext>(null);
Database.SetInitializer<MemberUsersContext>(null);
//Database.SetInitializer<ClubsContext>(null);
//AlertsContext db = new AlertsContext();
MemberUsersContext db = new MemberUsersContext();
//ClubsContext db = new ClubsContext();
//db.MemberUsers.ToList()
return View(db.MemberUsers.ToList());
}
This is what I have as the model for the View itself (to compile I remove the two that aren't under the @model IENumerable statement:
@model IEnumerable<GMC.Models.MemberUsers>
<div class="dashboard_alerts">
@Html.Partial("DashboardAlerts")
</div>
<div class="dashboard_pending_clubs">
@Html.Partial("DashboardClubs")
</div>
<div class="dashboard_verified_members">
@Html.Partial("DashboardMembers")
</div>
In each partial View the headers are as follows:
DashboardClubs
@model IEnumerable<GMC.Models.Clubs>
DashboardMembers
@model IEnumerable<GMC.Models.MemberUsers>
DashboardAlerts
@model IEnumerable<GMC.Models.Alerts>
Now my question is how do I pass the three database contexts into the Dashboard? I am thoroughly confused and am struggling.