1
Good afternoon, gentlemen.
I use DropDownListFor
To load lists, example load all my clients to be selected. However, I need that if a record does not appear in the listing have the option to add a new item.
I can write the code, however the problem is that the item to add a new record is at the end of my list, I would like it to be the second item. The first item is the select, second new and the others who are registered.
@Html.DropDownListFor(model => model.ClienteId, new SelectList(@ViewBag.Clientes, "Id", "Nome") ,"Selecione")
JS:
$('#ClienteId').append($('<option>', { text: "Novo", value: 0, selected: false }));
The insertAfter command was not recognized, for min.
– Zica
I gave an update on the reply. He came to see?
– Leonel Sanches da Silva
Oops, I hadn’t seen it. So, I tested code and no error occurred, but it didn’t work. "New"
– Zica
I think it will now appear. I just tested it here on a screen of mine. The first version was really wrong.
– Leonel Sanches da Silva
So para min didn’t work. The order shown is the order the data were entered.
– Zica