Bring selected combo box filled manually

3

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.

    
asked by anonymous 03.08.2015 / 14:11

1 answer

1

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));
    
03.08.2015 / 16:28