@Chhatrapati Sharma,
In your controller, try this,
ViewData['anyName'] = new SelectList { Text = , // text from ur function Value = , // Value from function Selected = // if required }
and, in this regard, link viewdata as,
<@Html.ListBox("docImages", ((IEnumerable<SelectListItem>)ViewData["anyName"]))
For testing, try selecting the selectlist element as follows:
ViewData['anyName'] = new List<SelectListItem>{ new SelectListItem {Text = "First", Value = "0"}, new SelectListItem {Text = "Second"), Value = "1"}, new SelectListItem {Text = "Third", Value = "2"} };
If this sample works, check your function "_supp.listDocImages ()" and make sure it returns an IList
Rifaj
source share