I am looking for a way to manually add items to html.ListBox in mvc. I want the top item to be “All Items”.
i.e.
All Items
Item1
Item2
Item3
I am currently calling:
<%=Html.ListBox("items", Model.Items, new { style = "height:50px;width:100%" })%>
I may have to add it in the model when setting up the MultiSelectList, but would be prefer to add this in the controller.
Cheers
You can simply have your view model contain a list of SelectListItem and add the item manually in the controller. For example: