live-love
live-love

Reputation: 52396

The type arguments for method 'SelectExtensions.DropDownListFor(HtmlHelper, Expression>, IEnumerable, string, object)' cannot be inferred

Getting this error, not sure what's causing it:

@model DelegatePortal.ViewModels.ImpersonateVendorViewModel
     @Html.DropDownListFor(model => model.Id, new SelectList(Model.Vendors, "Id", "Name"), "Choose a vendor", new { @class = "form-control form-control-sm " })

The type arguments for method 'SelectExtensions.DropDownListFor(HtmlHelper, Expression>, IEnumerable, string, object)' cannot be inferred from the usage.

Upvotes: 1

Views: 528

Answers (1)

live-love
live-love

Reputation: 52396

Check if you added all the properties in the View Model.

Mine was missing Id property:

 public class ImpersonateVendorViewModel
    {
        public int Id { get; set; }
        public List<Vendor> Vendors { get; set; }
    }

Upvotes: 1

Related Questions