Here is my code for my AddNewProductViewModel
using AccessorizeForLess.Data;
using System.Collections.Generic;
using System.ComponentModel.DataA
Use your controller to build the list, then call the list from the view.
Controller:
public static List GetDropDown()
{
List ls = new List();
lm = (call database);
foreach (var temp in lm)
{
ls.Add(new SelectListItem() { Text = temp.name, Value = temp.id });
}
return ls;
}
Call the Dropdown:
@Html.DropDownListFor(x => x.Field, PathToController.GetDropDown())