public ActionResult Index(string classid) { if (classid == null) { var cms = cb.GetClasses(); ViewBag.ClassID = new SelectList(cms, "ID", "ClassName"); return(View(sb.GetStudentModels(cms[0].ID))); } else { var cms = cb.GetClasses(); ViewBag.ClassID = new SelectList(cms, "ID", "ClassName"); return(View(sb.GetStudentModels(int.Parse(classid)))); } }
public ActionResult Create() { ViewBag.ProjectID = new SelectList(pb.GetProjects(), "ID", "ProjectName"); var cms = cb.GetClasses(); ViewBag.ClassID = new SelectList(cms, "ID", "ClassName"); if (cms.Count > 0) { int classid = cms[0].ID; ViewBag.StuNo = new SelectList(sb.GetStudentModels(classid), "StuNo", "StuName"); } else { ViewBag.StuNo = new SelectList(new List <StudentModel>(), "StuNo", "StuName"); } return(View()); }