شما میتونید آرایه ای از ورودی ها رو از ویو دریافت کنید ( به تعداد نامحدود ) و با استفاده از foreach اون ها رو داخل دیتابیس ذخیره کنید :
ویو :
<div class="form-group">
@Html.Label(item.LessonName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBox("inputValues", null, new { @class = "form-control"})
</div>
</div>
<div class="form-group">
@Html.Label(item.LessonName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBox("inputValues", null, new { @class = "form-control"})
</div>
</div>
<div class="form-group">
@Html.Label(item.LessonName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBox("inputValues", null, new { @class = "form-control"})
</div>
</div>
<div class="form-group">
@Html.Label(item.LessonName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBox("inputValues", null, new { @class = "form-control"})
</div>
</div>
// ...
کنترلر :
[HttpPost]
public ActionResult Test(params string[] inputValues)
{
foreach(var item in inputValues)
{
Model model = new Model
{
YourProperty = item,
// ...
}
db.Models.Add(model);
}
db.SaveChanges();
}