public ActionResult SaveRecords(FormCollection model) { if (ModelState.IsValid) { using (BusinessCategoryCtl db = new BusinessCategoryCtl()) { var BusinesscategoryidArray = model.GetValues("item.Businesscategoryid"); var BusinessidArray = model.GetValues("item.Businessid"); var CategoryidArray = model.GetValues("item.Categoryid"); for (Int32 i = 0; i < BusinesscategoryidArray.Length; i++) { BusinessCategoryClass obj_update = db.selectById(Convert.ToInt32(BusinesscategoryidArray[i])); if (!string.IsNullOrEmpty(Convert.ToString(BusinesscategoryidArray))) { obj_update.Businesscategoryid = Convert.ToInt32(BusinesscategoryidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(BusinessidArray))) { obj_update.Businessid = Convert.ToInt32(BusinessidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(CategoryidArray))) { obj_update.Categoryid = Convert.ToInt32(CategoryidArray[i]); } db.update(obj_update); } } } return(RedirectToAction("EditTable")); }
public ActionResult Edit(BusinessCategoryClass Obj_BusinessCategory) { using (BusinessCategoryCtl db = new BusinessCategoryCtl()) { if (ModelState.IsValid) { db.update(Obj_BusinessCategory); string sesionval = Convert.ToString(Session["EditPreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("EditPreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } return(View(Obj_BusinessCategory)); } }