title: Dependent dropdownlist in ASP.NET MVC
body: <p>At present I have two tables (Teams and Employees)
  I am populating the dropdownList for Teams perfectly, next I am trying to populate the second dropdownlist depending on the selectedId of Teams for Employees.</p>
  
  <p>Controller:</p>
  
  <pre><code> // GET: CalView
          public ActionResult Index(string ses, string DH)
          {     //Team Lead Members
                  var eID = Convert.ToInt32(Session["currentEmployeeID"]);
                  var EmpID = Session["currentEmpID"];
                  Employee obj = (from o in db.Employees
                                  where o.EnrollNumber == EmpID
                                  select o).FirstOrDefault();
  
                  Department dept = (from dep in db.Departments
                                     where dep.LeadBy == obj.EmployeeId
                                     select dep).FirstOrDefault();
                  //this works fine
                  ViewBag.showTeams = new SelectList(db.Teams.Where(tm =&gt; (tm.DeptID == dept.DepartmentId) &amp;&amp; (dept.LeadBy == eID)), "TeamID","Name");
                 //this obviously does not
                  ViewBag.showMembers = new SelectList(db.Employees.Where(empt =&gt; (empT.TeamID == selectedIdFromPreviousDropDownList), "EmployeeID", "Employee"));
  
                  return View();
          }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>if ((Session["UT"] == "DD") &amp;&amp; (@ViewBag.DeptLead != null))
    {
  //this works
    @Html.DropDownList("showTeams", null, "-Select Team-", htmlAttributes: new { @class = "form-control" })
  //this does not work
    @Html.DropDownList("showMembers", null, "-Select Team-", htmlAttributes: new { @class = "form-control" })
     }
  </code></pre>
  
  <p>Do I need some AJAX call? or perhaps a POST method? Totally new to MVC.</p>