The model item passed into the dictionary is of type 'System.Tuple`?

Here am implementing Tuple for using two models in my view.But am getting 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 am calling two partial views inside my view and getting 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 have answered this question(Edit)

Answers


Change:

@model Tuple<IEnumerable<MvcApplication1.Models.EventRepository>, IEnumerable<MvcApplication1.Models.SlideShow>>
    ViewBag.Title = "Home Page";
}

To

@model Tuple<List<MvcApplication1.Models.EventRepository>, IEnumerable<MvcApplication1.Models.SlideShow>>
    ViewBag.Title = "Home Page";
}

You're defining the model as IEnumerable yet you pass a List down in your return statement in the Controll Action (Index). You also have the alternative to pass down the IEnumerable if you wanted to keep the collection from being modified in your view.


For the new error, you can pass a specific part of the tuple to each partial:

@Html.Partial("EventDetails", Model.Item1)

@Html.Partial("SlideShow", Model.Item2)

But like @henk-holterman said, you should probably make a specific view model.


Answer for my Edit is @model Tuple<List<MvcApplication1.Models.EventRepository>, List<MvcApplication1.Models.SlideShow>>

Since we are returning the view with two collection of objects as a tuple we have to define both model in partial views


Need Your Help

Why “return” on PHP function is not stopping the process?

php return

I do not understand why "return" is not stopping the process in this function that I created to search a value on a multi_level array in PHP.

Issue installing node-postgres with npm (on windows)

windows node.js postgresql npm

I am trying to install pg on windows using npm, but receive the following error:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.