[英]Uncheck the checkbox within the gridview template field from server side
[英]Adding Records to Table from Template Field Checkbox selection and Gridview Boundfield
我目前正在使用C#在ASP.Net中構建考勤登記系統。 系統具有一個包含這些Sql表的數據庫;
Attendance Table
AttendanceID
Present (boolean type)
StudentID
Student Table
StudentID
StudentName
CourseID
Course Table
CourseID
CourseName
我已經用“課程表”填充了一個下拉列表,並基於該下拉列表中選擇的“課程CourseID
,從“學生”表中填充了一個CourseID
,在該表格中,“ studentID
和“ StudentName
與在下拉列表中選擇的相同的“ CourseID
一起顯示。 這很好。
直到登記冊被加入並添加記錄后,出勤表才包含任何記錄。
現在的有點棘手,在gridivew顯示所有StudentID
具有相同CourseID
基礎上, CourseID
在下拉列表中選擇。 gridview還具有帶有復選框的模板字段,這使用戶可以檢查該復選框是否存在該學生。
頁面上有一個SaveAttendance
按鈕。 一旦用戶單擊SaveAttendance
按鈕,我想將在gridview中顯示的所有StudentID
以及復選框的狀態(無論是否經過天氣檢查)分別添加到出勤表字段StudentID
和Present中。 盡快需要幫助,我們將不勝感激。 謝謝!
您可以使用以下語句訪問gridView中的任何控件:
Control control = gridView.Rows[rowIndex].Cells[cellIndex].FindControl(controlID);
然后,您可以將其轉換為正確的類型並獲取其屬性值:
Boolean checked = ((CheckBox) control).Checked;
我相信您需要閱讀一些教程:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.