我想编辑一个变量列表,并想为商品创建ID
public class UserProfileFormViewModel
{
public int UserProfileId { get; set; }
public string UserProfile { get; set; }
public virtual List<FormsAccess> FormsAccesses { get; set; }
}
public class FormsAccess
{
[Key]
public int Id { get; set; }
public Forms Form { get; set; }
public bool IsAccess { get; set; }
}
可见
foreach (var userProfileForm in Model.FormsAccesses)
{
Html.RenderPartial("_FormsAccessesEditorRow", userProfileForm);
}
和PartialView
@using (Html.BeginCollectionItem("FormsAccesses"))
{
var id = "FormsAccesses_"+@Model.Id+"__IsAccess";
@Html.HiddenFor(m => m.Id);
<input type="checkbox" id="@id" class="chk-col-red" />
<label for="@id">@Model.Form.GetDisplayName()</label>
}
但是当我单击提交按钮时,FormsAccesses为空。