我在模型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问题 –