【发布时间】:2012-10-11 11:48:29
【问题描述】:
我在尝试渲染 PartialView 时遇到了一些问题。
我的控制器:
public ActionResult Index()
{
var db = new fanganielloEntities();
List<imovel> imoveis = (from s in db.imovel
where s.StatusImovel == 3
select s).ToList();
return PartialView(imoveis);
}
public ActionResult Listar()
{
return View();
}
观点:
@Html.Partial("TesteLista")
部分:
@model List Mvc4Web.Models.imovel
@if (Model != null)
{
foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.DescricaoImovel)
}
}
错误:
对象引用未设置为对象的实例。
来源错误:
第 5 行:第 6 行:第 7 行:@foreach(模型中的变量项)第 8 行:{ 第 9 行:
提前致谢!!!
【问题讨论】:
标签: asp.net-mvc-3 asp.net-mvc-partialview