@model IEnumerable<Editing.Models.Table1> @using (Html.BeginForm("Index", "Home", new { Idt = item.Idt, col01 = item.col1, col02 = item.col2, col03 = item.col3 { <tr> <td> @Html.TextBoxFor(modelItem => item.Idt) </td> <td> @Html.TextBoxFor(modelItem => item.datetime0) </td> <td> @Html.TextBoxFor(modelItem => item.col1) </td> <td> @Html.TextBoxFor(modelItem => item.col2) </td> <td> @Html.TextBoxFor(modelItem => item.col3) </td> <td> <input type="submit" id="Edit" value="Edit" /> </td> </tr> }
public class HomeController : Controller { private testContext db = new testContext(); [HttpPost] public ActionResult Index(int Idt, string col01, string col02, string col03) { var dataToUpdate=db.Data1.SingleorDefault(o=> o.Idt ==Idt); dataToUpdate.datetime0=DateTime.Now.ToString(); dataToUpdate.col1=col01; dataToUpdate.col2=col02; dataToUpdate.col3=col03; db.Entry(dataToUpdate).State=EntityState.Modified; db.SaveChanges(); return View(db.Data1.ToList()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)