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 (モデルの var item) 8 行目: { 9 行目:
よろしくお願いします!!!