am trying to make cascading dropdown list in asp.net mvc 4, both values for my dropdown list's comes from methods, so am in trouble how to pass value form one dropdown list to another.
here's how i get values for the first dropdown list:
var CampaignInfo1 = CampaignManagementService.GetAdvertisers((string)Session["ticket"]);
List<CampaignList1> items1 = new List<CampaignList1>();
foreach (var element in CampaignInfo1)
{
items1.Add(new CampaignList1() { ID1 = element.Key, Name1 = element.Value });
}
var listOfCamp1 = new SelectList(items1, "ID1", "Name1", 1);
ViewData["list1"] = listOfCamp1;
and dropdown list in view:
@Html.DropDownList("list1", ViewData["list1"] as SelectList, "-- Select Client -1-")
the second dropdown list value am getting almost same method:
var CampaignInf = CampaignManagementService.GetCampaigns((string)Session["ticket"], IDFromfirstDDL);
List<AlreadyCreatedCampaignList> itemas = new List<AlreadyCreatedCampaignList>();
foreach (var element in CampaignInf)
{
itemas.Add(new AlreadyCreatedCampaignList() { campID = element.Key, campName = element.Value });
}
var listOfCam = new SelectList(i
temas, "campID", "campName", 1);
ViewData["clist"] = listOfCam;
But there is a problem that in method GetCampaigns i have to pass the id(IDFromfirstDDL) which i get from first DDL, and only then method return values which are for that id. The proble is that i dont know how to pass that selected value from first DDL to second, without any form submit, bicouse i need that second DDL changes his values immediately after first DDL changes.