【发布时间】:2011-08-20 13:46:08
【问题描述】:
我收到一个错误
错误 826 无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“OVR.Models.ChildInfoModel”。存在显式转换(您是否缺少演员表?) C:\dev.....\Controllers\NewRecordController.cs 129 34 OVR
public ActionResult ChildInfo(ChildInfoModel childInfoModel)
{
//INewRecord newRecord = (INewRecord)TempData["newRecord"];
if (TempData["CertNum"].ToString() == "")
{
return View();
}
else
{
string certNum = (string)TempData["CertNum"];
//call up Child Info Screen
var repo = new Get_Home_Repository();
childInfoModel = repo.Get_Screen_DataDS(certNum, "ChildInfo");
//childInfoModel = cModel;
return View(childInfoModel);
}
}
- TempData["CertNum"] 包含我需要的值
- 使用@model OVR.Models.ChildInfoModel 为模型强类型化视图
- 我在参数中添加了 (ChildInfoModel childInfoModel),但如果未单击链接,则将拉出空白页面并允许填写,否则我传入从存储库中提取数据所需的参数,然后填充接口 IChildInfo,其中包含来自列表的数据作为 IEnumerable。我想我可以以某种方式显式转换 .. 或者接口 IChildInfo 需要更新才能将模型传回视图。如何从存储库数据中填充模型?
【问题讨论】:
标签: asp.net-mvc-3