Here I use Tuple to use two models in my view. But I get the following error
The model item passed into the dictionary is of type 'System.Tuple`2[System.Collections.Generic.List`1[MvcApplication1.Models.EventRepository],System.Collections.Generic.List`1[MvcApplication1.Models.SlideShow]]', but this dictionary requires a model item of type 'System.Tuple`2[System.Collections.Generic.IEnumerable`1[MvcApplication1.Models.EventRepository],System.Collections.Generic.IEnumerable`1[MvcApplication1.Models.SlideShow]]'.
Here is my View :
@model Tuple<IEnumerable<MvcApplication1.Models.EventRepository>, IEnumerable<MvcApplication1.Models.SlideShow>> ViewBag.Title = "Home Page"; }
Controller:
[HttpPost] public ActionResult Index(string SearchParam) { EventRepository objcheckout = new EventRepository(); objcheckout.GetEventDetails(SearchParam); SlideShow SS = new SlideShow(); SS.GetSlideDetail(SearchParam); return View(Tuple.Create(objcheckout.GetEventDetails(SearchParam), SS.GetSlideDetail(SearchParam))); }
Any suggestion?
EDIT: Here I call two partial views inside my view and get this error
The model item passed into the dictionary is of type 'System.Tuple`2[System.Collections.Generic.List`1[MvcApplication1.Models.EventRepository],System.Collections.Generic.List`1[MvcApplication1.Models.SlideShow]]', but this dictionary requires a model item of type 'System.Collections.Generic.List`1[MvcApplication1.Models.EventRepository]'.
Here is my view
@model Tuple<IEnumerable<MvcApplication1.Models.EventRepository>, IEnumerable<MvcApplication1.Models.SlideShow>> @Html.Partial("EventDetails") @Html.Partial("SlideShow")
and partial view 1
@model List<MvcApplication1.Models.EventRepository>
partial view 2
@model List<MvcApplication1.Models.SlideShow>
Answer: I answered this question (Edit)
source share