/// <summary> /// Creates an HTML name/value list for use with dropdowns, etc /// </summary> /// <returns></returns> static string ToHtmlList(string listFormat, string checkedFlag, IEnumerable enumerable, object selectedValue, string valueField, string textField) { SelectList list = new SelectList(enumerable, valueField, textField, selectedValue); StringBuilder sb = new StringBuilder(); string selected = ""; List<System.Web.Mvc.ListItem> items = list.GetListItems().ToList(); foreach (System.Web.Mvc.ListItem item in items) { selected = item.Selected ? checkedFlag : ""; sb.AppendFormat(listFormat, item.Value, selected, item.Text); } return sb.ToString(); }