我得到我的详细信息该错误的浏览页面:错误页:传递到字典的模型产品类型“System.Data.Entity.DynamicProxies
The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.cpd_certificates_65AF30842281867E2F4F6A1026590271109C12A85C8175394F14EF6DE429CBC7', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[cpd.Models.cpd_certificates]'.
这是我的控制器:
public class Default8Controller : Controller
{
//
// GET: /Default8/
private cpdDbContext db = new cpdDbContext();
public ActionResult Index()
{
return View(db.CPD.ToList());
}
//
// GET: /Default8/Details/5
public ActionResult Details(int id)
{
cpd_certificates cpd_ = db.Cert.Find(id);
return View(cpd_);
}
下面是我详细查看:
@model IEnumerable<cpd.Models.cpd_certificates>
@{
ViewBag.Title = "Details";
}
<h2>Details</h2>
<table>
<tr>
<th>
certificateNo
</th>
<th>
Mark
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.CertificateNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.Mark)
</td>
</tr>
}
</table>
下面是cpd_certificates型号:
public class cpd_certificates
{
[Key]
public int CertificateNo { get; set; }
public int QuizNo { get; set; }
public DateTime? DateReceived { get; set; }
public DateTime? DatePaid { get; set; }
public string Mark { get; set; }
public int? AccreditationNo { get; set; }
public int? ID { get; set; }
public virtual cpd_recipients Recipients { get; set; }
}
我有两个型号,我可以在我的索引视图列表。我希望当我点击详细信息链接时,它会将我所获证书的详细信息以及另一个模型/表格中的考试详细说明。所以简而言之,有两种型号在证书上有CPD和FK ID的PK ID。索引页面只显示个人信息,此页面没有问题。 单击详细信息时,会显示其他模型/表格数据,即该人员的许多证书。
可以显示@莫希特 - 阿罗拉我已经编辑和posetd模型来回证书cpd.Models.cpd_certificates模式 –
。 – Sithelo