如何在模型的侧面填充数组以进行回发
我有一个包含Milestone
列表的模型,我希望在网页中使用给定的一组文本框填充(在模型内)列表。
public class Project { public string ProjectNumber { get; set; } public IList Parameters; public IList MilestoneList = new List(); }
在我的Html.BeginForm("Edit", "Home", FormMethod.Post, new { Project = Model }))
我有以下TextBox。
@for (int i = 0; i < Model.MilestoneList.Count; i++) { @Html.TextBoxFor(model=>model.MilestoneList[i].Value) }
我的控制器在milestonelist下面的问题在模型Project中始终为null
[HttpPost] public ActionResult Edit(Project project) { helper.CreateProject(project, System.Web.HttpContext.Current.User.Identity.Name); return View(); }
那么我应该如何编程,以便模型中的列表将通过TextBoxes填充?
您在模型中使用字段,而不是属性,因此DefaultModelBinder
无法设置该值。 将模型更改为
public class Project { public string ProjectNumber { get; set; } public IList Parameters { get; set; } public IList MilestoneList { get; set; } }
并在控制器中初始化集合。
- 是否可以在asp.net中使用静态LINQ to SQL DataContext维护事务?
- Windows azure REST API列出容器问题
- 访问ListView的LayoutTemplate内的控件
- 我如何在asp.net的datagridview列中显示总和
- 什么是Visual Studio 2017中的entity framework’数据库优先’的替代品
- 使用Gmail发送电子邮件。 错误:服务器响应为:5.5.1需要身份validation
- ASP.NET Web服务器无法启动,Mono环境无法切换
- 在.NET中记录StackOverflowException
- 从动态添加的文本框中获取值asp.net c#