You must Sign In to post a response.
  • Category: ASP.Net MVC

    Work with table to insert multiple rows with validations in MVC5

    I want to create 1 form where I can insert multiple records into database in list format.
    Example :
    I have 1 table with 1 row and 4 columns, Leave Type, From Date, To Date Weekend.
    Below that row, there will be button to add another row.

    Here, I have to create it in MVC5 using table to bind the data.
    Here, there is by default 1 row bind. Then on click on "add new" button, new row will be added.

    It should follow server side validations as well as client side validation like row Y not overlapped with row X like this.
    Means, I want to get values depends on row number same like we do it in asp net grid view.

    Please suggest some flow / sample / link if anyone know that.
  • #768371
    This is the example of code snippet to insert multiple row to database using MVC with validations
    public ActionResult BulkData(List<ContactInfo> ci)
    if (ModelState.IsValid)
    using (MyDatabaseEntities dc = new MyDatabaseEntities())
    foreach (var i in ci)
    ViewBag.Message = "Data successfully saved in database!";
    ci = new List<ContactInfo> { new CInfo{ ID = 0, CName = "", CNo= ""} };
    return View(ci);

  • #768376
    Just go through this article where you can find Insert/Edit operation on WebGrid of MVC using JQuery:

  • Sign In to post your comments