public ActionResult Edit(componentClass Obj_component) { using (componentCtl db = new componentCtl()){ if (ModelState.IsValid) { db.update(Obj_component); string sesionval = Convert.ToString(Session["EditPreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("EditPreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } return(View(Obj_component)); } }
public ActionResult SaveRecords(FormCollection model) { if (ModelState.IsValid) { using (componentCtl db = new componentCtl()){ var ComponentidArray = model.GetValues("item.Componentid"); var ComponentnameArray = model.GetValues("item.Componentname"); for (Int32 i = 0; i < ComponentidArray.Length; i++) { componentClass obj_update = db.selectById(Convert.ToInt32(ComponentidArray[i])); if (!string.IsNullOrEmpty(Convert.ToString(ComponentidArray))) { obj_update.Componentid = Convert.ToInt32(ComponentidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(ComponentnameArray))) { obj_update.Componentname = Convert.ToString(ComponentnameArray[i]); } db.update(obj_update); } } } return(RedirectToAction("EditTable")); }