The model item passed into the dictionary is of type 'Mvc3Practice.Models.ReportModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Mvc3Practice.ViewModels.ReportViewModel]'.
The model item passed into the dictionary is of type 'Mvc3Practice.Models.ReportModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Mvc3Practice.ViewModels.ReportViewModel]'.
You do have a (partial ) view with the Model IEnumerable<ReportViewModel>, but you pass a ReportModel as an Model.
Dear GM123 You have to create a model for that page. It should not reflect anything from the database for the moment. Please create a IEnumerable variable of type you want to use for results Create a constructor, and pass Web.UI.Page to it from the main View.
In the constructor you can fill the IEnumerable from the DB and then use in the partial view In the View Page you can use like this var model = new MyProject.Models.MyCustomModel(this.Page); then use the variable model in the page to send to the partial view
in the controller of the page you can just return view(); MyIenumVar is the variable you declared in the custom Model Class and the filled in the Constructor. In case anything still remains to be understood. Please ask me.
GM123
Member
44 Points
58 Posts
Multiple Models in one View using MVC3 & C#
Jan 30, 2013 03:19 PM|LINK
Hi I have one View with two sections, Search and Results and have two models for Search and results.
I have created two partial pages for search and results and both of them called in view.
In search partial page select the values and submit button and then show the result in result partial page.
When run it shows the Search section but as soon as add the results partial page then get the error and unable to see the search section.
Any body can guide me how can i do this,
Thanks
ignatandrei
All-Star
134871 Points
21618 Posts
Moderator
MVP
Re: Multiple Models in one View using MVC3 & C#
Jan 30, 2013 03:34 PM|LINK
some error code and stack trace will help
GM123
Member
44 Points
58 Posts
Re: Multiple Models in one View using MVC3 & C#
Jan 30, 2013 03:39 PM|LINK
Hi, I am getting this error.
The model item passed into the dictionary is of type 'Mvc3Practice.Models.ReportModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Mvc3Practice.ViewModels.ReportViewModel]'.
Thanks for your attentions.
ignatandrei
All-Star
134871 Points
21618 Posts
Moderator
MVP
Re: Multiple Models in one View using MVC3 & C#
Jan 30, 2013 07:18 PM|LINK
You do have a (partial ) view with the Model IEnumerable<ReportViewModel>, but you pass a ReportModel as an Model.
asad.malik
Member
218 Points
103 Posts
Re: Multiple Models in one View using MVC3 & C#
Jan 31, 2013 05:35 AM|LINK
Regards
Asad Malik
Mark as answer if it helps