I want to add Drop Down List html control to the web page fill it with products list. My Action controller looks like
public ActionResult Index()
{
return View(_repository.GetProducts(true));
}
Product model (Linq to SQL, below is partial class where SelectedId is for drop down selection id)
public partial class Product
{
public int SelectedId { get; set; }
}
The view is
@model IQueryable<Entity.Product>
@Html.DropDownListFor(.....)
What I do not understand how to fill up DropDownList with Products and if product selected bind Id to SelectedId property.