Reference that can help you understand the code.
This part here I pass the values that will be added in the second DropDown
var classesList = this.GetClasses(Convert.ToInt32(CanalMassivo));
var classesData = classesList.Select(m => new SelectListItem()
{
Value = m.idSegmento.ToString(),
});
var states = classesData.Select(m => m.Value).ToList();
return Json(states, JsonRequestBehavior.AllowGet);
In the Value = m.idSegmento.ToString()
part and the value that appears in the DropDown as the value that the controller receives.
How could I do to pass the description in DropDown and the controller receive the id value?
I tried this way
Text = m.descricao.ToString(),
Value = m.idSegmento.ToString(),
});
var states = classesData.Select(m => m.Text).ToList();
But it generates this error
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'idCanalIndicadoresMassivo'.