gpt4 book ai didi

c# - 获取错误 : Object reference not set to an instance of an object

转载 作者:太空宇宙 更新时间:2023-11-03 19:05:51 26 4
gpt4 key购买 nike

<分区>

谁能帮我解决这个问题:

我需要在我的 _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();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com