编辑:删除部分视图以使事情更简单。现在我只需要找出为什么视图没有发布值
ViewModelProspectUsers
public class ViewModelProspectUsers { public int Id { get; set; } public string User { get; set; } public IEnumerable<ViewModelProspectSelect> Prospects { get; set; } }
ViewModelProspectSelect
public class ViewModelProspectSelect { public int ProspectID { get; set; } public string Name { get; set; } public bool IsSelected { get; set; } }
看法
@model OG.ModelView.ViewModelProspectUsers @using (Html.BeginForm()) { @Html.HiddenFor(model => model.Id) <h5>Please Select Prospects you wish to assign to this User.</h5>
-----这里是以前的部分,这些值没有被发布到[Post]
方法------
-----------------------------------------但是他们的人口很好--- -------------------------------------
@foreach (var item in Model.Prospects)
{
@Html.HiddenFor(x => item.ProspectID)
@Html.DisplayFor(x => item.Name)
@Html.EditorFor(x => item.IsSelected)
}
@*@Html.Partial("_ShowProspectCheckedForUser", Model.Prospects)*@
@*@Html.Partial("_ShowProspectCheckedForuser", new OG.ModelView.ViewModelProspectSelect())*@
<input type="submit" value="Save changes" />
@Html.ActionLink("Cancel", "Index")
}
邮政
[HttpPost] public ActionResult UsersInProspect(ViewModelProspectUsers viewModel)
如果我要查看viewModel.Prospects(m=>m.isSelected)
//<- 这个值为 Null 不应该是
我的视图模型变量显示数据,但不显示 Ienumerable。