为什么GridView Control“Cells”的属性不显示。 任何人都可以帮我解决这个问题吗?
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach(GridView row in GridView1.Rows)
{
int enrollment = Convert.ToInt32(row.Cells[0].Text);
String student1 = row.Cells[1].Text;
RadioButton rbt1 = (row.Cells[2].FindControl("Present") as RadioButton);
RadioButton rbt2 = (row.Cells[2].FindControl("Absent") as RadioButton);
String status;
if(rbt1.Checked)
{
status = "Present";
}
else
{
status = "Absent";
}
String date = DateTime.Now.ToShortDateString();
String division = txtDepartment.SelectedValue;
String shift = txtShift.SelectedValue;
String year = txtYear.SelectedValue;
SaveAttendance(enrollment, student1, date, status, division, shift, year);
}
Response.Write("<script>alert('Attendance Saved SuccessFully !!')</script>");
}
答案 0 :(得分:0)
您应该在[bar:rab, foo:oof, baz:zab]
循环中使用GridViewRow
代替GridView
foreach