0

モデル クラスGradeがあり、その int リスト プロパティは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 リストでチェック済みの PayHeadIds を取得したい

4

0 に答える 0