Ok I have the following Code
#region getDurationListDD
private List<KeyValuePair<int, int>> getDurationListDD
{
get
{
List<KeyValuePair<int, int>> dDur = new List<KeyValuePair<int, int>>();
dDur.Add(new KeyValuePair<int, int>(2, 2));
dDur.Add(new KeyValuePair<int, int>(3, 3));
dDur.Add(new KeyValuePair<int, int>(4, 4));
dDur.Add(new KeyValuePair<int, int>(7, 7));
dDur.Add(new KeyValuePair<int, int>(14, 14));
dDur.Add(new KeyValuePair<int, int>(21, 21));
return dDur;
}
}
#endregion
Then the following in the main ActionResult...
ViewData["changeDuration"] = new SelectList(getDurationListDD, "Key", "Value", Duration);
this on the view
Html.DropDownList("changeduration", (SelectList)ViewData["changeDuration"])
Now if the Duration was set (i.e. int Duration = 7;) then I'd expect that 7 would be selected, but for some reason it isn't. Any hints before I give up trying and do something more productive?
Ta