I have a list which I created in the controller:
var PayList = new[] {
new ListEntry { Id = 1, Name = "" },
new ListEntry { Id = 2, Name = "Yes" },
new ListEntry { Id = 3, Name = "No" }
};
ViewBag.PayList = new SelectList(PayList, "Id", "Name",2);
In the View I have the following:
@Html.DropDownList("Pay", ViewBag.PayList as SelectList)
I was expecting the above to default to Yes but did not happen(Note that I am passing 2 in the ViewBag.PayList.