fill data in dropdown box as per previous dropdown box data selected in aspnet mvc 1

Posted by FosterZ on Stack Overflow See other posts from Stack Overflow or by FosterZ
Published on 2010-05-14T07:12:43Z Indexed on 2010/05/14 7:14 UTC
Read the original article Hit count: 430

Filed under:

hi, i'm buildin' an employee registration form in aspnet mvc, i have fields like "School" list in 1 dropdown box and "Department" list another, problem is i want to show Department list on change of School list, i have done followin' code:


public ActionResult EmployeeCreate()
{
   var getSchool = SchoolRepository.GetAllSchoolsInArray();//this gets school_id as value and school_name as text for dropdown box
   ViewData["SchoolsList"] = getSchool;

   return View();
} 


[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EmployeeCreate()
{
   _employeeRepository.CreateEmployee(employeeToCreate);
   _employeeRepository.SaveToDb();
} 

Here is the View


Html.DropDownList("SchoolLists")
Html.DropDownList("DepartmentLists") 

now, how do i get the departments of selected school in dropdown boxes

© Stack Overflow or respective owner

Related posts about asp.net-mvc