lundi 24 mai 2021

Get Checkbox value from the database into a table row (MVC)

This may be a simple question but I am new to MVC. So please bear with me.

I want to get the checkbox value into the table row. Here is my code for the table.

<tbody>
  @foreach (var itms in Model.takeoverdlist)
     {
       <tr id="@itms.TAKEOVER_D_id">
          <td class="text-left">
          <input type="hidden" name="tasklist[]" id="task_id" value="@(itms.TAKEOVER_D_id)" />
          </td>

          <td class="text-left">
          <input type="text" id="task@(itms.TAKEOVER_D_id)" name="task@(itms.TAKEOVER_D_id)" value="@(itms.TAKEOVER_D_task)" style="width:100%" />                                            
          </td>

          <td class="text-left">
          <input type="text" id="amnt@(itms.TAKEOVER_D_id)" name="amnt@(itms.TAKEOVER_D_id)" value="@(itms.TAKEOVER_D_amount)" style="width:100%" />                                            
          </td>

          <td class="text-left">
          <input type="checkbox" id="donebit@(itms.TAKEOVER_D_id)" name="donebit@(itms.TAKEOVER_D_id)" value="@(itms.TAKEOVER_D_done)" style="width:100%" />                                            
          </td>

       </tr>
  }

I get other values just fine, but the checkbox is unchecked. It should be checked.

When I inspect the table the value for the checkbox is "value".




Aucun commentaire:

Enregistrer un commentaire