Class constructor SelectList

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);

Guess you like

Origin www.cnblogs.com/bwdblogs/p/11026496.html