尝试在一个 View 中渲染多个模型时遇到问题。
假设我有:
型号
public int ID { get; set; }
public ArrayOfThings[] Things { get; set; }
查看
for (int i = 0; Model.Things.Count() > i; i++)
{
using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { Id = i }))
{
<p>@Html.CheckBoxFor(m => m.Things[i].IsDone, "Some Check")</p>
<input type="submit" title="Delete" value="Check as Done" name="btn_submit" />
}
}
我该怎么做才能使输入(提交)按钮与正确的表单相关联?实际上,只有第一种形式受到影响。
最佳答案
我认为也许您需要改变主意。 你为什么要创造新的形式?? 您可以使用操作链接代替提交按钮并通过 ActionLink 参数发送数据。
<%=Html.ActionLink("Link Text", "Action", "Controller", new {id = "1"}, null)%>
关于c# - submit 和 beginform 的相关性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16673122/