To get a drop-down list for displaying text elements, but return a numeric identifier, you must pass it a SelectList through your model.
public SelectList Shops
{
get
{
var list =
from shop in myDataContext.Shops
Select shop;
return new SelectList(list, "ShopID", "ShopDescription");
}
}
Then, in your opinion:
<%= Html.DropDownList("ShopID", Model.Shops) %>
source
share