public ActionResult SaveRecords(FormCollection model) { if (ModelState.IsValid) { using (CountriesCtl db = new CountriesCtl()){ var CountryidArray = model.GetValues("item.Countryid"); var CountrynameArray = model.GetValues("item.Countryname"); var IsactiveArray = model.GetValues("item.Isactive"); var IsdeletedArray = model.GetValues("item.Isdeleted"); var CreatedonArray = model.GetValues("item.Createdon"); var DeletedonArray = model.GetValues("item.Deletedon"); for (Int32 i = 0; i < CountryidArray.Length; i++) { CountriesClass obj_update = db.selectById(Convert.ToInt32(CountryidArray[i])); if (!string.IsNullOrEmpty(Convert.ToString(CountryidArray))) { obj_update.Countryid = Convert.ToInt32(CountryidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(CountrynameArray))) { obj_update.Countryname = Convert.ToString(CountrynameArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(IsactiveArray))) { obj_update.Isactive = Convert.ToBoolean(IsactiveArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(IsdeletedArray))) { obj_update.Isdeleted = Convert.ToBoolean(IsdeletedArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(CreatedonArray))) { obj_update.Createdon = Convert.ToDateTime(CreatedonArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(DeletedonArray))) { obj_update.Deletedon = Convert.ToDateTime(DeletedonArray[i]); } db.update(obj_update); } } } return(RedirectToAction("EditTable")); }
public ActionResult Edit(CountriesClass Obj_Countries) { using (CountriesCtl db = new CountriesCtl()){ if (ModelState.IsValid) { db.update(Obj_Countries); string sesionval = Convert.ToString(Session["EditPreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("EditPreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } return(View(Obj_Countries)); } }