First off, I agree with @AndrewCounts. You doubt a fairly broad question, and it will be difficult to give answers to quality answers. However, I can give you general guidance, which I hope will keep you going.
, , , . , :
GET
public ActionResult CreateMyModels()
{
var myModels = new List<MyModel>();
for (var i = 0; i < totalItems; i++)
{
myModels.Add(new MyModel());
}
return View(myModels)
}
@model List<Namespace.To.MyModel>
@using (Html.BeginForm())
{
for (var i = 0; i < Model.Count(); i++)
{
}
<button type="submit">Submit</button>
}
for foreach , . , Html.EditorFor, Razor , .
undefined , . Modelbinder name :
ListName[index].FieldName
POST :
[HttpPost]
public ActionResult CreateMyModels(List<MyModel> myModels)
:
myModels[0].FirstField
myModels[0].SecondField
...
myModels[1].FirstField
...
JavaScript, , , name .
, POST . , . Entity Framework , MVC . , :
[HttpPost]
public ActionResult CreateMyModels(List<MyModel> myModels)
{
if (ModelState.IsValid)
{
foreach (var myModel in myModels)
{
db.MyModels.Add(myModel);
}
db.SaveChanges();
return RedirectToAction("Index");
}
return View(myModels);
}