在ASP.NET MVC中,可以使用循环和表单绑定来实现编辑单列的所有行。以下是一个示例解决方法:
public class RowModel
{
public int Id { get; set; }
public string Value { get; set; }
}
public class MainModel
{
public List Rows { get; set; }
}
@model MainModel
@using (Html.BeginForm("SaveRows", "Home", FormMethod.Post))
{
for (int i = 0; i < Model.Rows.Count; i++)
{
@Html.HiddenFor(m => m.Rows[i].Id)
@Html.TextBoxFor(m => m.Rows[i].Value)
}
}
[HttpPost]
public ActionResult SaveRows(MainModel model)
{
// 保存编辑后的数据
return RedirectToAction("Index");
}
通过以上步骤,你可以在ASP.NET MVC中实现编辑单列的所有行,并保存修改后的数据。