//[ValidateInput(false)] //thuộc tính public ActionResult Edit(khachhang kh) { if (ModelState.IsValid) { //thực hiện cập nhật trong model db.Entry(kh).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Session["Taikhoan"] = kh; } return(RedirectToAction("Details", "Nguoidung")); }
//[ValidateInput(false)] //thuộc tính public ActionResult Edit(khachhang kh) { //c1: tạo đối tượng //sanpham sp1 = db.sanphams.SingleOrDefault(n => n.sanpham_id = sp.sanpham_id); //sp1.sanpham_name = sp.sanpham_name; //db.SaveChanges(); //c2: if (ModelState.IsValid) { //thực hiện cập nhật trong model db.Entry(kh).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }
//[ValidateInput(false)] //thuộc tính public ActionResult Edit(sanpham sp) { //c1: tạo đối tượng //sanpham sp1 = db.sanphams.SingleOrDefault(n => n.sanpham_id = sp.sanpham_id); //sp1.sanpham_name = sp.sanpham_name; //db.SaveChanges(); //c2: if (ModelState.IsValid) { //thực hiện cập nhật trong model db.Entry(sp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } ViewBag.theloai_id = new SelectList(db.theloaisps.ToList(), "theloai_id", "theloai_name", sp.theloai_id); return(RedirectToAction("Index")); }