I tried searching and didn\'t find anything that fixed my problem. I have a DropDownList on a Razor view that will not show the the item that I have marked as Selected in th
My solution was this... Where the current selected item is the ProjectManagerID.
View:
@Html.DropDownList("ProjectManagerID", Model.DropDownListProjectManager, new { @class = "form-control" })
Model:
public class ClsDropDownCollection
{
public List DropDownListProjectManager { get; set; }
public Guid ProjectManagerID { get; set; }
}
Generate dropdown:
public List ProjectManagerDropdown()
{
List dropDown = new List();
SelectListItem listItem = new SelectListItem();
List tempList = bc.GetAllProductManagers();
foreach (ClsProjectManager item in tempList)
{
listItem = new SelectListItem();
listItem.Text = item.ProjectManagerName;
listItem.Value = item.ProjectManagerID.ToString();
dropDown.Add(listItem);
}
return dropDown;
}