"CODE 01: Data update form does the validation correctly but it does not update the records in the table. "
"There's similar code which I have used as an example, which is "CODE 02" that code work but the other does not .... "
"I did accordingly to the CODE 02, but CODE 01 does not work"
@* CODE 01 *@
public ActionResult Edit(Film F)
{
if (ModelState.IsValid) {
var item3 = db.Films.Where(x => x.Id == F.Id).First();
item3.Title = F.Title;
item3.Director = F.Director;
item3.Actor = F.Actor;
item3.Year = F.Year;
item3.Budget = F.Budget;
ModelState.Clear();
db.SaveChanges();
ViewBag.alert = "Your data is updated";
}
return View(F);
}
@* CODE 02 *@
public ActionResult Edit(Film E) {
var item3 = db.Films.Where(e=> e.Id==E.Id).First();
item3.Title = E.Title;
item3.Director = E.Director;
ViewBag.alert = "Data is success";
db.SaveChanges();
return View();
}
CODE 01 doesnt update the data but CODE 02 does upadate it