Class constructor SelectList
SelectList constructor (the IEnumerable, String, String, Object)
1.IEnumerable
specifies the items in the list to be
2.String
name attribute, which attribute contains the value when the user selects a specific item used
3.String
each text to be displayed
4.Object
contains the initial value of the selected item
example:
Album album = db.Albums.Find(id);
ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);