public ActionResult Create([Bind(Include = "Id,StudentId,ParentMobileNo,PrimaryTagId,SecondaryTagId,EmailId,StudentName,SchoolBranchId,ClassId,SectionId")] StudentDetail studentDetail) { if (ModelState.IsValid) { db.StudentDetails.Add(studentDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Name", studentDetail.ClassId); ViewBag.PrimaryTagId = new SelectList(db.TagDetails, "Id", "TagId", studentDetail.PrimaryTagId); ViewBag.SchoolBranchId = new SelectList(db.SchoolBranches, "Id", "Name", studentDetail.SchoolBranchId); ViewBag.SecondaryTagId = new SelectList(db.TagDetails, "Id", "TagId", studentDetail.SecondaryTagId); ViewBag.SectionId = new SelectList(db.Sections, "Id", "Name", studentDetail.SectionId); return(View(studentDetail)); }