Depending on the complexity of your screen I suggest using Javascript for this, but then I made an example with a different alternative, to give you some ideas, I hope it helps you:
Add the file to your header:
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
Control code:
public static class DropDownDB
{
public static List<string> Nomes = new List<string> { "Nome 1", "Nome 2", "Nome 3" };
}
public class DropDownController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string nome)
{
DropDownDB.Nomes.Add(nome);
return MeuDrop();
}
public ActionResult MeuDrop()
{
return PartialView("MeuDrop", new SelectList(DropDownDB.Nomes));
}
}
Of View:
@model string
@using (Ajax.BeginForm(null, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "replaceDiv", OnSuccess = "$('.text').val('');" }))
{
<input type="text" name="nome" />
<button type="submit">Adicionar</button>
}
<div id="replaceDiv">
@Html.Action("MeuDrop")
</div>
And of Partial View created for the dropdown:
@model SelectList
@DateTime.Now
@Html.DropDownList("drop", Model)