0
    [HttpPost]
    public ActionResult check(List<tbl_checklist> chk)
    {

        db.tbl_checklist.AddRange(chk);
        db.SaveChanges();

      return RedirectToAction("den_list", "denetim");
    }

As you see,i want list data from view.But i can not

Satinder singh
  • 10,100
  • 16
  • 60
  • 102
  • Can you please refer this: https://stackoverflow.com/questions/13242414/passing-a-list-of-objects-into-an-mvc-controller-method-using-jquery-ajax – Jimesh Oct 09 '20 at 06:09
  • why you cannot? what stops you from doing this? – Beingnin Oct 09 '20 at 06:57

1 Answers1

0

This is the approach I use, which uses Kendo but doesn't have to: https://onallthingsweb.wordpress.com/2016/06/27/asp-net-mvc-and-client-side-lists-with-kendo/

Essentially, using this model as an example:

public  class SystemTestModel
{
   public List Entities { get; set; }
}

public class SystemListEntity
{
   public string Name { get; set; }
   public string Value { get; set; }
   public bool IsDeleted { get; set; }
}

You can bind to the Entities property like this:

for (var i = 0; i < Model.Entities.Count; i++)
{
   <tr>
      <td>
          
          <input type="hidden" name="@Html.NameFor(m => m.Entities[i].IsDeleted)" value="@Boolean.FalseString" />
      </td>
      <td>
          <input type="text" value="#= Value #" name="@Html.NameFor(m => m.Entities[i].Value)" />
      </td>
   </tr>
}

When this form is posted back to the server, your action method will receive all the data as necessary:

public ActionResult Index(SystemTextModel model)
{
    foreach (var entity in model.Entities)
    {
        //the data in the UI is passed back to the server
    }
}
Brian Mains
  • 50,520
  • 35
  • 148
  • 257