0

我有一个模型类Grade,它有一个 int list 属性PayHeads。我怎样才能用最简单的方法实现这一点,或者如果有另一种方法,请告诉我是 ASP.NET MVC 助手的新手,我不想使用 jQuery 或 Ajax:

    public int GradeId { get; set; }
    public int IncrementMonth { get; set; }
    public List<int> PayHeadIds { get; set; }

看法

@using (Html.BeginForm("Save", "Grade", FormMethod.Post))
{ 
    @Html.AntiForgeryToken();
    @Html.HiddenFor(model => model.GradeId)
    @Html.HiddenFor(model => model.Operation)
    @Html.HiddenFor(model => model.PayHeadIds, new { @Id="hdnPayHeadIds" })

    <div class="form-row">
        <div class="form-group col-md-4">
            @Html.LabelFor(g => g.Code, new { @class = " form required" })
            @Html.TextBoxFor(g => g.Code, new { @class = "form-control", placeholder = "Code" })
            @Html.ValidationMessageFor(g => g.Code, null, new { @class = "text-danger" })
        </div>
        <div class=" form-group col-md-3">
            @Html.LabelFor(g => g.IncrementMonth, new { @class = "required" })
            @Html.TextBoxFor(g => g.IncrementMonth, new { @class = "form-control", placeholder = "Increment Month" })
            @Html.ValidationMessageFor(g => g.IncrementMonth, null, new { @class = "text-danger" })
        </div>
        <div class=" form-group col-md-3">
            @Html.LabelFor(g => g.IsUnion, new { @class = "icheck-label form-label cursor-pointer" })
            <br />
            @Html.CheckBoxFor(g => g.IsUnion, new { @class = "skin-flat-blue", data_div = "divPF" })
            @Html.ValidationMessageFor(g => g.IsUnion, null, new { @class = "text-danger" })
        </div>
    </div>
    <hr />
    <table class="table table-bordered" id="tblEmployeeExperience">
        <thead>
            <tr>
                <th>#</th>
                <th>Select</th>
                <th>PayHead</th>
            </tr>
        </thead>
        <tbody>
            @if (ViewBag.PayHeadList != null)
            {
                int c = 0;

                foreach (var p in ViewBag.PayHeadList)
                {
                     c++;
                     <tr>
                         <td>@c</td>
                         <td>
                             <input type="checkbox" class="chkPayHead" id="chkPayHead(@p.PayHeadId)" value="@p.PayHeadId" />
                         </td>
                         <td>@p.Name</td>
                     </tr>
                 }
             }
         </tbody>
    </table>

    <button class="btn btn-success" type="submit">Submit</button>
    <a href="@Url.Action("AddEdit", "Grade")">
        <input type="button" class="btn btn-warning" value="Clear" />
    </a>
    <a href="@Url.Action("Index", "Grade")">
        <input type="button" class="btn btn-dark" value="Back" />
    </a>
}

我想在上面的 Int List 中获取选中的 PayHeadIds

4

0 回答 0