I am using MVC5, Razor and C#
I have a traditional MVC dropdownlist.
@Html.DropDownListFor(model => model.Car, (SelectList)ViewBag.CarSelectList, " -- Please Select --")
I want convert this into an editable dropdown, which I have done using the JQuery Editable Select plugin, see: JQuery Editable Select WebPage using:
$(function () {
$("#Car").editableSelect();
});
This all works fine. However when I type in a custom car that is not in the SelectList, it gets saved away, but when I refresh the edit page, the dropdown does not show the custom car ie "KitCar1". I suspect this is to do with the fact that this "KitCar1" is not in the select list and therefore cannot be matched. However how can I display "KitCar1" in the editable drop when I redisplay the page.
The only idea I have had is to show "Model.Car" in a seperate read-only "div" which works, but its is not a great solution.
Thoughts appreciated.
Aucun commentaire:
Enregistrer un commentaire