Проблема с ViewData и ViewBag в ASPNET Core - PullRequest
0 голосов
/ 26 сентября 2019

У меня проблема с ViewData и ViewBag в ASP.NET Core.Это моя часть кода контроллера:

    public IActionResult Create()
    {
        ViewData["item.CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId");
        AddressesBackOfficeCreateViewModel model = new AddressesBackOfficeCreateViewModel();
        model.item = new Addresses();
        return View(model);
    }

и эта часть кода cshtml

     <div class="form-group">
            <label asp-for="item.CustomerId" class="control-label"></label>
            <select asp-for="item.CustomerId" class ="form-control" asp-items="ViewBag.CustomerId"></select>
     </div>

Проблема в том, что выпадающий список клиентов пуст.

Кто-нибудь может мне помочь?Заранее спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...