我在這裏實現元組在我view.But使用兩種機型正在以下錯誤傳入字典的模型項目類型爲「System.Tuple」?
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]]'.
這裏是我的查看:
@model Tuple<IEnumerable<MvcApplication1.Models.EventRepository>, IEnumerable<MvcApplication1.Models.SlideShow>>
ViewBag.Title = "Home Page";
}
控制器:
[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)));
}
有什麼建議嗎?
編輯: 我在這裏叫我的觀點裏兩個部分意見和收到此錯誤
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]'.
這裏是我的觀點
@model Tuple<IEnumerable<MvcApplication1.Models.EventRepository>, IEnumerable<MvcApplication1.Models.SlideShow>>
@Html.Partial("EventDetails")
@Html.Partial("SlideShow")
和 局部圖1
@model List<MvcApplication1.Models.EventRepository>
局部圖2
@model List<MvcApplication1.Models.SlideShow>
Answer:
我已經回答了這個問題(編輯)
你可以(應該)當然寫一個特殊(查看)模型的場合... – 2013-05-14 10:01:36