Vinculando el valor actual a la pantalla de SelectList

I've been able to correctly display a dictionary as a dropdownlist as well as pull it's value on a page submit. But on the GET (initial display) the selected item does not reflect the object's value. My controller is passing state:

ViewData["Status"] = new SelectList(AppHelper.WebinarStatuses, "Key", "Value", selectedStatus);

la vista:

<%: Html.DropDownListFor(m => m.Status, (ViewData["Status"] as SelectList), Model.Status )%>

I understand that I need to find the right overload of the DropDownListFor helper - I don't understand how I go about doing that. Small picture, what syntax forces the select list to display what the controller's sending - bigger picture, how do I discover/interpret which overload does what?

profuse thanks

preguntado el 09 de marzo de 12 a las 13:03

do you assign any value to Status property of model? -

I've verified that the final param ('selectedStatus' in the code above) in the controller's assignment is correctly populated. So, yes, the controller's doing it's part - the problem is the view's rendering. -

tu usas DropDownListFor helper so you have to set selected value to Status propiedad. -

right - but at which parameter? -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.