【发布时间】:2020-12-29 10:40:22
【问题描述】:
学生考勤班
public class StudentAttendance
{
public int Id { get; set; }
public int StudentID { get; set; }
public bool IsPresent { get; set; }
}
查看我的出勤表表格
@foreach (var student in Model.Students)
{
<tr>
<td> @student.FullName</td>
<td><input type="hidden" asp-for="HiddenID" id="id" value="@student.StudentID"/></td>
<td ><label class="col-form-label"><input type="checkbox" name="IsPresent" ></label></td> </tr> }
出勤页面模型
[BindProperty]
public StudentAttendance studentAttendance { get; set; }
[BindProperty]
public List<int> StudentAttendanceList { get; set; }
[BindProperty(SupportsGet = true)]
public int? SearchClassID { get; set; }
[BindProperty]
public List<int> HiddenID { get; set; }
[BindProperty]
public bool IsPresent { get; set; }
public IEnumerable<Student> Students { get; set; }
出勤率()
foreach (var id in HiddenID)
{
Conn.StudentAttendance.Add(new StudentAttendance
{
StudentID = id,
IsPresent = IsPresent,
});
}
当我提交并保存时,即使选中,IsPresent 值仍然为假
【问题讨论】:
标签: asp.net asp.net-core razor entity-framework-core