I am very new to ASP.NET and I am using the MVC 3 framework of ASP.Net. I was trying to filter the options of a dropdown list using another drop down and I can\'t manage to
You need to add another method to handle the postback and filter the sub-category options. Something like this:
[HttpPost]
public ActionResult Create(TestQuestionsViewModel model)
{
model.SubCategories = resetDB.SubCategories
.Where(sc => sc.categoryid == model.SubCategoryId)
.OrderBy(sc => sc.subcategoryid);
return View(model);
}
Edit
Btw, if you still need to set the class name to the other drop-down, you can't do it like that. The easiest way would by to add a "SelectedCategoryName" property to your model, and reference like { @class = ModelSelectedCategoryName }.