KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to bind a dropdown in MVC3 in this way. Model public static Dictionary<string, string> SexPreference() { var dict = new Dictionary<string, string>(); dict.Add("Straight", "S"); dict.Add("Gay", "G"); dict.Add("Bisexual", "BISEX"); dict.Add("Bicurious", "BICUR"); return dict; } Controller ViewBag.SexPreference = MemberHandler.SexPreference(); View @{ var itemsSexPreference = new SelectList(ViewBag.SexPreference, "Value", "Key", Model.sexpreference); } @Html.DropDownListFor(m => m.sexpreference, @itemsSexPreference) Dropdown is not selecting the selected value, don't know why.
Tags (comma-separated)
Save Edits
Cancel