Hello,
When I need to use a lookup I usually include the ID property in the view model class so I can use it this way in the corresponding view
<%= Html.LabelFor( model => model.LookupTableID )%>
<br />
<%= Html.DropDownListFor(model => model.LookupTableID, Model.LookuptableList, new {}) %>
having Model.LookuptableList
as a property in the Model itself like this:
public IEnumerable<SelectListItem> LookuptableList {
get {
return GetLookuptableList().Select(
t => new SelectListItem { Text = t.Description, Value = t.LookupTableID.ToString() } );
}
}
But I am not sure that this is a good way to handle this because of the function GetLookuptableList()
inside the view model class.
is there a better/cleaner way to do this?