I am using MVC Core with repository Pattern to handle operations. I am trying to generate a select
element using DropDownListFor
but recieve the following error:
The ViewData item that has the key 'Products.CategoryId' is of type 'System.Int32' but must be of type 'IEnumerable'
The main model(Products) with be using data as IEnumerable<SelectListItem>
from other models. Here is the code in the (Products) View:
@HTML.DropDownListFor(c => c.Products.CategoryId, Models.CategoryList, "--Select Category--", new { @class = "form-control" })