MVC Razor在for循环中使用CheckBoxFor

时间:2013-04-22 07:39:48

标签: asp.net-mvc razor

我的观点型号:

public class SendFileDeviceViewModel
  {
    public string DeviceName { get; set; }
    public int DeviceId { get; set; }
    public string ManagementGroupName { get; set; }
    public int ManagementGroupId { get; set; }
  }

  public class SendFileManagementGroupViewModel
  {
    public string ThisManagementGroupName { get; set; }
    public List<SendFileDeviceViewModel> DeviceList { get; set; }
  }

我的观点:

@model Ceridian.Wfm.DeviceManager.Models.Terminals.SendFileManagementGroupViewModel
@{
  ViewBag.Title = "Index";
  Layout = "~/Areas/Terminals/Views/Shared/Master/_TerminalLayout.cshtml";
}
@section termimalContent {


  @using (Html.BeginForm())
  {
    @Html.ValidationSummary(true)

    foreach (var dev in Model.DeviceList)
    {


    <fieldset>
        <legend>@dev.DeviceName - [ @dev.ManagementGroupName ]</legend>

          @Html.CheckBoxFor(m => m.

        </fieldset>
    }
    }
  }

lambda返回我的整个模型,而不是dev的内容。可以帮忙吗

1 个答案:

答案 0 :(得分:0)

抱歉,在SO

上找到了这个
@Html.CheckBoxFor(m => dev.reloadConfiguration)