0

I need to implement check all checkbox which will check and uncheck the checkboxes in rows.

   <table id="instruments" class="table table-bordered table-striped table-condensed table-hover smart-form has-tickbox" style="width: 100%;">
    <thead>
        <tr>
            <th>
                                                               
                <input type="checkbox"/>
                                                               
            </th>
                                                            
            <th data-class="expand" style="white-space: nowrap">@Model.SResource</th>
            <th data-hide="phone" style="white-space: nowrap">@Model.KResource</th>
            <th data-hide="phone" style="white-space: nowrap">@Model.LocationResource</th>
        </tr>
    </thead>
    <tbody>
        @for (int i = 0; i < Model.Instruments.Count; i++)
        {
            var values = Model.Instruments[i].Value.Split('~');
            var status = values.Length > 0 ? values[0] : "";
            var location = values.Length > 1 ? values[1] : "";

            <tr>
               <td>
                   <label class="checkbox">
                         @Html.CheckBoxFor(m => m.Instruments[i].Selected)
                         <i></i>
                    </label>
                </td>
                <td><label>@Model.Instruments[i].Text</label></td>
                <td><label>@status</label></td>
                <td><label>@location</label></td>
            </tr>
                                                        }
    </tbody>
</table>

on this table @Html.CheckBoxFor is setting selected in model which I want it to remain as it is. Can anyone help?

freedomn-m
  • 24,983
  • 7
  • 32
  • 55

0 Answers0