2 luxiaoxie1991 luxiaoxie1991 于 2013.12.23 01:23 提问

对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();
    }
}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!