问题描述
- 对GridView的一列数据进行修改,点击保存后,数据并没有更新
-
protected void Button1_Click(object sender, EventArgs e)
{for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; string connString = "Data Source=ilovefamily\mysql;Initial Catalog=Student;Integrated Security=True"; SqlConnection conn = new SqlConnection(connString); conn.Open(); String sql = "UPDATE Score SET 成绩='" + row.Cells[4].Text + "' WHERE 学号= '" + row.Cells[0].Text + "' AND 授课老师='" + (string)Session["TID"] + "'"; SqlCommand comm = new SqlCommand(sql, conn); comm.ExecuteNonQuery(); conn.Close(); } }
时间: 2024-09-17 04:18:38