MVCContrib 网格:
@model ViewModel
@using (Html.BeginForm("SendData", "Home", FormMethod.Post))
{
@Html.Grid(Model.List).Columns(c =>
{
c.For(x => x.Id);
c.For(x => x.Name);
c.For(x =>Html.Partial("Partial/CheckBoxTemplate", new CheckBoxViewModel { Id = x.Id })).Named("Options");
})
@Html.SubmitButton()
}
控制器发布操作:
public ActionResult SendData(List<CheckBoxViewModel> list)
{
return View();
}
视图模型:
public class CheckBoxViewModel
{
public int Id { get; set; }
public bool CheckBox { get; set; }
}
public class ViewModel
{
public IPagination<Data> List { get; set; }
}
public class Data
{
public int Id { get; set; }
public string Name { get; set; }
}
局部视图:
@model MvcApplication1.Models.CheckBoxViewModel
@Html.HiddenFor(x => x.Id)
@Html.CheckBoxFor(x => x.CheckBox)
默认情况下,所有复选框都未选中。
如何在我的SendData
操作中检索所有选中的复选框值?