How can I add an item to a SelectList in ASP.net MVC

Posted by Barrigon on Stack Overflow See other posts from Stack Overflow or by Barrigon
Published on 2009-03-21T02:07:17Z Indexed on 2010/04/29 0:27 UTC
Read the original article Hit count: 839

Filed under:
|

Basically I am looking to insert an item at the beginning of a SelectList with the default value of 0 and the Text Value of " -- Select One --"

Something like

SelectList list = new SelectList(repository.func.ToList());
ListItem li = new ListItem(value, value);
list.items.add(li);

Can this be done?

Cheers

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about selectlist