Having a hard time finding answer to this question (Google, StackOverflow and ASP.NET).
// Model
public IEnumerable<SelectListItem> State { get; set; }
// View
@Html.DropDownListFor(m => m.State, ????)
// Controller
using (var dbcontext = MyDbContext()) {
// ??
}
return View(model);
I'm at a complete loss how to populate a mvc dropdownlistfor using LINQ from a DBContext. I understand the DBContext thing and have one setup. I'm not clear on how to construct a linq query and then pass that result (LIST?) to the DropDownListFor helper? Using MS SQL and I have a States table (id, name).