1
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 part Value = m.idSegmento.ToString()
and the value that appears in Dropdown when the controller receives.
How could I pass the description in Dropdown and the controller receive the id value ?
I tried so
Text = m.descricao.ToString(),
Value = m.idSegmento.ToString(),
});
var states = classesData.Select(m => m.Text).ToList();
But it makes that mistake
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'idCanalIndicadoresMassivo'.
Post as is your
view
with theDropDown
. You are probably usingidCanalIndicadoresMassivo
when it should just beValue
.– Randrade
Randrade, thank you. Could you access here? http://answall.com/questions/100716/dropdown-cascata which has all the beginning of my code, View, Controlle, Model, Javascript
– Edgar Araujo