Saving Multiple records in asp.net MVC 5
Add view to the following action
view screen shot
multiple records can be saved at once into the database using asp.net MVC 5. In this article i will show how to save multiple records at once to the database.
Add controller to your application1 | using System; |
Add view to the following action
[HttpGet]
public ActionResult SaveMultiple()
{
int _recordsToEnter = 5;
List lst = new List();
for (int i = 1; i <= _recordsToEnter; i++)
{
lst.Add(new Device() { DeviceID = i, DeviceName = "", NumberOfDevices=0 });
}
return View(lst);
}
View SaveMultiple.cshtmlpublic ActionResult SaveMultiple()
{
int _recordsToEnter = 5;
List
for (int i = 1; i <= _recordsToEnter; i++)
{
lst.Add(new Device() { DeviceID = i, DeviceName = "", NumberOfDevices=0 });
}
return View(lst);
}
1 | @model List<MyApp.Models.Device> |
view screen shot
Enter some data into the fields and click save button
debug screen shot
Post a Comment
Post a Comment