我在模型NewsDetail
中有一個視圖,我剛剛編輯了News Index View
上的所有數據,並希望通過單擊它獲取詳細信息。但每當我點擊它,我得到這個錯誤The model item passed into the dictionary is of type 'CricketTest2.Models.NewsDetail', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable 1[CricketTest2.Models.NewsDetail]'.
。我已經盡力解決它。請幫我解決他的問題。謝謝 這裏是我的代碼片段。傳入字典的模型項目類型爲'CricketTest2.Models.NewsDetail',
News Controller + NewsDetail Model
News Index and News Details View
添加
@model CricketTest2.Models.NewsDetail
讓我試試@Mahbubur –它給錯誤... 類型參數的方法「System.Web.Mvc.Html.DisplayExtensions.DisplayFor中(系統。 Web.Mvc.HtmlHelper ,System.Linq.Expressions.Expression >)'不能根據用法推斷。嘗試明確指定類型參數 –
通過刪除foreach循環解決了Brother問題 –