Question :
I’m having trouble creating a combo of “Enabled” and “Disabled” by passing the value of the bank to bring it filled. In my controller , I created the following code:
InmyView,followingcode:
Theresultisthat,withthecoderunning,itwillalwaysappear”Enabled” in the combo.
Answer :
Since gestor.Status
is a bool, or you change Value
to bool:
lista.Add(new SelectListItem { Text = "Habilitado", Value = "True" });
lista.Add(new SelectListItem { Text = "Desabilitado", Value = "False" });
Or convert your gestor.Status
to integer:
ViewBag.Status = new SelectList(lista, "Value", "Text", Convert.ToInt32(gestor.Status));