It is probably easy as you might say it is. But the fact remains is that I can not find the solution anywhere.
Here is my code:
public ActionResult Edit([DataSourceRequest] DataSourceRequest gridRequest, Sub editSub)
{
if (ModelState.IsValid)
{
Sub subToUpdate = db.Subs.FirstOrDefault();
subToUpdate.SFirst = editSub.SFirst;
subToUpdate.SLast = editSub.SLast;
subToUpdate.SEmail = editSub.SEmail;
db.SaveChanges();
}
return Json(new[] { editSub }.ToDataSourceResult(gridRequest, ModelState));
}
Every time I modify a different row the first row gets overwritten. I assume that I nee to specify the ID in here: db.Subs.FirstOrDefault();
I cannot find how to?