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
Please find sample code below.
public class Temp
{
public int id { get; set; }
public string valueString { get; set; }
}
Controller
public ActionResult Index()
{
// Assuming here that you have written a method which will return the list of Temp objects.
List temps = GetList();
var tempData = new SelectList(temps, "id", "valueString",3);
ViewBag.Statuses = tempData;
return View();
}
View
@Html.DropDownListFor(model => model.id, (SelectList)ViewBag.Statuses)
@Html.ValidationMessageFor(model => model.id)