【发布时间】:2017-05-26 10:53:30
【问题描述】:
我想将学生出勤率从剃刀视图检索到控制器。在一行中,我想访问单选按钮值。并且有很多行。如何一次访问所有行数据并将其发送到控制器?
我的 Razor 视图是:
<table class="table">
<thead class="thead-inverse">
<tr>
<th>Full Name</th>
<th>Roll No</th>
<th>Status</th>
@* <th>Status</th>*@
</tr>
</thead>
<tbody>
@using (@Html.BeginForm("Save", "Attendance", FormMethod.Post, new { @class = "form-horizontal" }))
{
foreach (var student in Model.Students)
{
<tr>
<td>@student.Name</td>
<td>@student.RollNo</td>
<td>
<div data-toggle="buttons">
<label class="btn btn-success active">
<input type="radio" name="options" id="1" autocomplete="off" checked> Present
</label>
<label class="btn btn-danger">
<input type="radio" name="options" id="2" autocomplete="off" checked> Absent
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="3" autocomplete="off" checked> On Leave
</label>
<label class="btn btn-warning">
<input type="radio" name="options" id="4" autocomplete="off" checked> Short Leave
</label>
</div>
</td>
</tr>
}
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
}
</tbody>
</table>
我附上了我网页的屏幕截图,以便您可以看到我想要实现的目标。
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 razor model-view