jeudi 26 octobre 2017

table cshtml with checkbox

@model List<Models.Myclient>

<br />
<br />
<br />

@using (Html.BeginForm())
{

    <table class="table">
    <tr>

        <th>
           Name
        </th>
        <th>
           Adress
        </th>
        <th>
           Confirmation
        </th>
    </tr>


@for (int i = 0; i < Model.Count; i++)
{

        <tr>
            <td>
                @Html.DisplayFor(modelItem => Model[i].Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => Model[i].Address)
            </td>
            <td>
                @Html.CheckBoxFor(modelItem => Model[i].Confirmation)
            </td>
        </tr>
}

</table>

<br />
<br />

<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <input type="submit" value="Create" class="btn btn-default" />
    </div>
</div>
}

This is my view, the input type is a List of Models.MyClient, when i submit form why the model contain only the value of checkbox? I need a way to pass into controller after submit all fields : Name, Address, Confirmation. The final result is a table, for every row ther's the checkbox and when click onsubmit will be the value of every fields and not only the checkbox.




Aucun commentaire:

Enregistrer un commentaire