I have a controller that takes in an instance of getbldgaddr_Result
. I am trying to create a view that uses partials to put two separate viewmodels on the page. Below is the "Parent View"
@using DirectoryMVC.Models
@model Tuple<getbldgaddr_Result,getadministrators_Result>
@{
ViewBag.Title = "Central Office";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Central Office</h2>
<div class="row">
@*Display the getAddress view*@
@Html.Partial("_BuildingAddress", Model.Item1)
</div>
So above I am using Item1 from the model that is a getbldgaddr_Result
. I have tried casting it to getbldgaddr_Result
as well, but I get the below error.
The model item passed into the dictionary is of type 'System.Tuple`2[DirectoryMVC.Models.getbldgaddr_Result,DirectoryMVC.Models.getadministrators_Result]', but this dictionary requires a model item of type 'DirectoryMVC.Models.getbldgaddr_Result'.
The actual controller is...
public class BuildingAddressController : Controller
{
private DirectoryEntities de;
public BuildingAddressController()
{
de = new DirectoryEntities();
}
// GET: BldgAddr
public ActionResult BldgAddr(getbldgaddr_Result bldgres)
{
//getbldgaddr_Result bldgResult = de.getbldgaddr(district, bldg_no, null).FirstOrDefault();
return View(bldgres);
}
}
My guess is, I can have it take a tuple object as the parameter, but this seems counter intuitive. the Building Address, does not need anything in regards to administration. Any thoughts?