My model as below:
public class Product
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
}
Index Controller as below:
public ActionResult Index(int id)
{
return View(GetProducts()); //Get Product return List
}
My Post controller as below: It is posting back entire list. I need only updated records.
public ActionResult Update(List<Prouct> Proucts)
{
}
View as below:
@model List<Product>
@using (Html.BeginForm("Update", "Product", FormMethod.Post, new {Proucts=Model})) {
for (var i = 0; i < Model.count(); i++)
{
@Html.HiddenFor(v => Model[i].Id)
@Html.TextBoxFor(m => Model[i].Name)
</div>
<button type="submit" title="Save">
}
SO when posting back it post entire list (including the updated). e.g. if there are 100 products it post back 100. Even If I changed 1 or none. So I have to update all again.
Is there way to post only changed records?