c# - The model item passed into the dictionary is of type 'System.Tuple`? -
here implementing tuple using 2 models in view.but getting following error
the model item passed dictionary of type 'system.tuple`2[system.collections.generic.list`1[mvcapplication1.models.eventrepository],system.collections.generic.list`1[mvcapplication1.models.slideshow]]', dictionary requires model item of type 'system.tuple`2[system.collections.generic.ienumerable`1[mvcapplication1.models.eventrepository],system.collections.generic.ienumerable`1[mvcapplication1.models.slideshow]]'. here 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 calling 2 partial views inside view , getting error
model item passed dictionary of type 'system.tuple`2[system.collections.generic.list`1[mvcapplication1.models.eventrepository],system.collections.generic.list`1[mvcapplication1.models.slideshow]]', dictionary requires model item of type 'system.collections.generic.list`1[mvcapplication1.models.eventrepository]'. here 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 question(edit)
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 model ienumerable yet pass list down in return statement in controll action (index). have alternative pass down ienumerable if wanted keep collection being modified in view.
Comments
Post a Comment