<分区>
谁能帮我解决这个问题:
我需要在我的 _DeliveryDetailsPatial.cshtml
中显示动态数据。每次用户进入“投递信息”页面或“新地址”页面时都会调用此方法。每次我要导航到这些页面中的任何一个时,我都会不断收到此错误:
Object reference not set to an instannce of an object
我该如何解决这个问题?
谢谢!
这是我的代码:
_DeliveryDrtailsPartial
:
@model QuiznosOnlineOrdering.Models.StoreViewModel
<table id="orderTable" class="table">
<tr>
<td class="t">Item</td>
<td class="t">Quantity</td>
<td class="t">Item Price</td>
</tr>
@foreach (var item in Model.StoreAddress)
{
<tr>
<td>@Html.DisplayFor(model => item.NOM)</td>
<td>@Html.DisplayFor(model => item.ADRESSE)</td>
<td>@Html.DisplayFor(model => item.VILLE)</td>
</tr>
}
</table>
StoreViewModel
:
public IEnumerable<Store> StoreAddress { get; set; }
public IEnumerable<StoreHour> StoreHour { get; set; }
public IEnumerable<ReferenceAcceptedPayment> StoreAcceptedPayment { get; set; }
DeliveryController
:
[HttpGet]
public ActionResult GetStoreDetails()
{
StoreViewModel store = new StoreViewModel();
store.StoreAddress = from s in db.Store
select s;
return View();
}