Haven't really tested this out, but you could try something like this:
public void ListCDropDownList(string code)
{
var itemsQuery = from k in db.listCs where k.code == code select k ;
ViewBag.ItemsList = itemsQuery.ToList();
}
public ActionResult Index(string code)
{
ListCDropDownList(code);
var menuList = db.listAs.ToList();
return View(menuList.OrderBy(x => x.MenuItem).ToList());
}
Then you can modify your
DropDownListFor
declaration to this:
@Html.DropDownListFor(item => item.Code, new SelectList(ViewBag.ItemsList, "ItemName",
"ItemName"), "Please Select", new { @class = "form-control" })