I've had some problems when I try to render a PartialView.
My Controller:
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();
}
The View:
@Html.Partial("TesteLista")
The Partial:
@model List Mvc4Web.Models.imovel
@if (Model != null)
{
foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.DescricaoImovel)
}
}
The Error:
Object reference not set to an instance of an object.
Source Error:
Line 5: Line 6: Line 7: @foreach (var item in Model) Line 8: { Line 9:
Thank in advanced!!!