foreach (Person person in personList) {
SelectListItem item = new SelectListItem();
item.Value = person.Id;
item.Text = person.FirstName + " " + person.LastName;
items.Add(item);
}
ViewData["personSelectList"] = new SelectList(items, "Value", "Text", 4);
<%=Html.DropDownList("personId", ViewData["personSelectList"] as SelectList)%>
This code is not setting the person with Id = 4 as the selected item, but rather always picking the first item in the list as the selected item.
What step am I missing?