我有一个创建列表并将其返回到我的视图的操作。
public ActionResult GetCustomers()
{
return PartialView("~/Views/Shared/DisplayTemplates/Customers.cshtml", UserQueries.GetCustomers(SiteInfo.Current.Id));
}
在“~/Views/Shared/DisplayTemplates/Customers.cshtml”视图中,我有以下内容:
@model IEnumerable<FishEye.Models.CustomerModel>
@Html.DisplayForModel("Customer")
然后我在“~/Views/Shared/DisplayTemplates/Customer.cshtml”视图中:
@model FishEye.Models.CustomerModel
@Model.Profile.FirstName
我收到错误消息:
The model item passed into the dictionary is of type System.Collections.Generic.List`1[Models.CustomerModel]', but this dictionary requires a model item of type 'Models.CustomerModel'.
它不应该为 Customers.cshtml 中集合中的每个项目显示 Customer.cshtml 吗?
帮助!