这是我的代码:
楷模
public class InformationsModel
{
public List<InformationModel> infos { get; set; }
public InformationsModel()
{
}
}
public class InformationModel
{
public InformationModel() {
}
public string Name { get; set; }
public string Value { get; set; }
public string Group { get; set; }
public string Type { get; set; }
public bool Avaiable { get; set; }
}
看法
@model InterfaceWeb.Models.InformationsModel
@using (Html.BeginForm("UpdateInformations", "Main", FormMethod.Post, new { @id = "frmInformations" }))
{
@Html.EditorFor(x => x.infos)
}
模板
@model InterfaceWeb.Models.Information.InformationModel
<div class="infoMain">
<div class="colunas">
@Html.TextBoxFor(x => x.Name, new { style = "width:250px;" })
</div>
<div class="colunas">
@Html.TextBoxFor(x => x.Value, new { style = "width:120px;" })
</div>
<div class="colunas">
@Html.TextBoxFor(x => x.Group, new { style = "width:120px;" })
</div>
<div class="colunas">
@Html.TextBoxFor(x => x.Type, new { style = "width:150px;" })
</div>
<div class="colunas">
@Html.CheckBoxFor(x => x.Avaiable, new { style = "width:10px; margin-left:20px;" })
</div>
</div>
控制器
[HttpPost]
public ActionResult UpdateInformations(InformationsModel infos)
{
}
当我到达控制器时,我的模型是空的,我不知道为什么。
我试图更改模板、视图、在之后、之前初始化列表,但没有任何效果..
感谢您的帮助!=)