This question already has an answer here:

Can anyone help me with this:

I need to display dynamic data in my _DeliveryDetailsPatial.cshtml. This is called every time the user is in the Delivery Information page or New Address page. Every time I am to navigate to either of these pages i keep getting this ERROR:

Object reference not set to an instannce of an object

How can I solve this?

Thank you!

Here's my code:


@model QuiznosOnlineOrdering.Models.StoreViewModel
<table id="orderTable" class="table">
            <td class="t">Item</td>
            <td class="t">Quantity</td>
            <td class="t">Item Price</td>
        @foreach (var item in Model.StoreAddress)
                <td>@Html.DisplayFor(model => item.NOM)</td>
                <td>@Html.DisplayFor(model => item.ADRESSE)</td>
                <td>@Html.DisplayFor(model => item.VILLE)</td>


    public IEnumerable<Store> StoreAddress { get; set; }
    public IEnumerable<StoreHour> StoreHour { get; set; }
    public IEnumerable<ReferenceAcceptedPayment> StoreAcceptedPayment { get; set; }


public ActionResult GetStoreDetails()
    StoreViewModel store = new StoreViewModel();
    store.StoreAddress = from s in db.Store
                             select s;

    return View();

Related posts

Recent Viewed