I am having an issue deserializing my SelectList
inside an object. My class is set up like so:
public class DropDownControl
{
public string Type
{
get { return "ddl"; }
}
public SelectList Values { get; set; }
}
The object I have created is simply
var myControl = new DropDownControl()
{
Values = new SelectList(
new List<SelectListItem>
{
new SelectListItem {Value = "1", Text = "A"},
new SelectListItem {Value = "2", Text = "B"},
new SelectListItem {Value = "3", Text = "C"},
}, "Value", "Text", "1"
)
}
and I am getting the error
Cannot create and populate list type System.Web.Mvc.SelectList.
When calling
JsonConvert.DeserializeObject<List<Control>>(myControl, _settings);
Certainly there has to be some way to serialize/deserialize a SelectList
?
>(json, _settings)`
– Barry Tormey Aug 07 '14 at 18:21