I want to give the user to option to add an item to a dropdownlist. I have tried implementing a couple of different solutions, but haven't been able to get the added item to appear in the list.
Currently, I am adding the item to the table and then recalling the HttpGet method to recreate the selectlist. The correct SelectList is created and sent to the View.
Controller:
Names= db.Contacts.ToList()
View:
@Html.DropDownListFor(m => m.Contact.ContactID,new SelectList(Model.Names.ToList(), "ContactID", "Name"), "")
The correct SelectList is being passed from the Controller to the View (i.e. the added item is included in the list) and when I step through the code, the View contains the correct list. However, the View is not being re-rendered.
Any help on this issue would be greatly appreciated!