I'm developing an application, where I have a ViewBag listing a list of numbers, from my database.
I need to save the selected number in this dropdown, in another ViewBag. I do not know how to do this, could anyone help me?
ViewBag returning the list of numbers:
ViewBag.Contrato = usuarioRepository.Lista.Where(u => u.sLogin == autenticacaoProvider.UsuarioAutenticado.Login).Select(u => u.SqContrato);
View with DropDownList:
@Html.DropDownList("Contrato", new SelectList(ViewBag.Contrato, "Contrato"))
Is there any syntax, such as "@Html.DropDownListFor (@ViewBag)"?