Super simple implementation of multiselect list box in Edit view
Using MVC4 here with EF and CF (badly)
I have a class like this:
public class Feature
{
public int ID { get; set; }
public string Desc { get; set; }
}
And one like this:
public class Device //change to Devices
{
public int ID { get; set; }
public string Name { get; set; }
public virtual ICollection<Feature> Features { get; set; }
}
On the Edit view for the Device model I would like for there to be a
ListBox that contains all elements of the Feature model (Desc property
displayed) with those features contained in the device.Features collection
pre-selected.
Then, when the user clicks Save on the Edit view, the current collection
of selected items in the ListBox gets written back to the device's
Features collection.
What does the controller code and cshtml look like for this trick?
Thank you for your time, Dave
No comments:
Post a Comment