【发布时间】:2016-04-25 09:11:11
【问题描述】:
我有一个包含Milestone 列表的模型,我希望在网页中使用一组给定的文本框填充该列表(在模型内部)。
public class Project
{
public string ProjectNumber { get; set; }
public IList<Parameter> Parameters;
public IList<Milestone> MilestoneList = new List<Milestone>();
}
在我的Html.BeginForm("Edit", "Home", FormMethod.Post, new { Project = Model })) 中,我有以下文本框。
@for (int i = 0; i < Model.MilestoneList.Count; i++)
{
<td style="align-content: center;">@Html.TextBoxFor(model=>model.MilestoneList[i].Value)</td>
}
我在里程碑列表下方的控制器中的问题始终是模型项目中的null
[HttpPost]
public ActionResult Edit(Project project)
{
helper.CreateProject(project, System.Web.HttpContext.Current.User.Identity.Name);
return View();
}
那么我应该如何编程以便模型内的列表将通过 TextBoxes 填充?
【问题讨论】:
标签: c# asp.net arrays asp.net-mvc model