控制器:
OnePersonAllInfoViewModel vModel = new OnePersonAllInfoViewModel();
vModel.PreferredContactType = new PreferredContactType();
ViewBag.PrefContactTypes = new SelectList(dbEntities.PreferredContactTypes
.OrderBy(pct => pct.PreferredContactTypeID),
"PreferredContactTypeID", "PreferredContactType1",
vModel.PreferredContactType.PreferredContactTypeID);
看法:
<div class="editor-label">
@Html.LabelFor(model => model.PreferredContactType.PreferredContactTypex)
</div>
@Html.DropDownListFor(model => model.PreferredContactType.PreferredContactTypeID,
ViewBag.PrefContactTypes as SelectList)
我在回发时收到此错误...没有“IEnumerable”类型的 ViewData 项目具有键“PreferredContactType.PreferredContactTypeID”
有什么想法吗?谢谢!