I have 3 dropdownlist, one I fill it from the controller (I already managed to fill it) but I want that as soon as I select a value from the first dropdown, that value is used for a query and fill the second dropdown, and from the second, the third.
How could I populate it from controller or list?
I've seen that I could fill it from the view like so:
@Html.DropDownListFor(model => model.Modelo, dbTablaParallenar.Select(x => new SelectListItem { Text = x.ToString() }))
but how could I filter what dbTablaParallenar has?
or as a second option, like this I fill the first dropdownlist:
var tabla1= from ee in contextoBd.dbTabla1
select ee.Id;
var tabla2= (from u in contextoBd.dbTabla2
where dbTabla2.Contains(u.Id)
select new
{
u.Id,
u.Descripcion
}).ToList();
Tabla2.Add(new { Id= "00", Descripcion = "-- Seleccione -- " });
var lista= new SelectList(Tabla2.OrderBy(o => o.Id), "Id", "Descripcion");
ViewData["Lista"] = lista;
But how could I fill the following dropdownlist as soon as the first value is selected?
You can do the following with JQuery an Ajax Request
@id = "ddl_CSN" You add the ID to your Dropdownlist in the HTML
and catch the change event in your Control as follows