GridView 编辑之后,点击更新之后,显示的内容还是修改之前的,内容没有更新呢。代码如下:
SqlConnectioncon=newSqlConnection("server=6F109672583647B\\SQLEXPRESS;database=教务管理;i...
SqlConnection con = new SqlConnection("server=6F109672583647B\\SQLEXPRESS;database=教务管理;integrated security=true");
con.Open();
string sql = "update 课表信息 set courseNumber='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text
+ " ',courseName='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox2")).Text +
" ',start_time='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox3")).Text +
" ',end_time='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox4")).Text +
" ',credit='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox5")).Text +
" ' where courseNumber='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text + " '";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
string sql1 = "update 班级课表 set college='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox6")).Text + "',class='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox7")).Text + "' where courseNumber='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text + " '";
SqlCommand cmd1=new SqlCommand (sql1,con );
cmd1.ExecuteNonQuery ();
con.Close();
Response.Write("<script language='javascript'>alert('修改成功!')</script>");
GridView2.EditIndex = -1;
this. bind();
两条语句是因为里面的信息来自不同的表! 展开
con.Open();
string sql = "update 课表信息 set courseNumber='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text
+ " ',courseName='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox2")).Text +
" ',start_time='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox3")).Text +
" ',end_time='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox4")).Text +
" ',credit='"
+ ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox5")).Text +
" ' where courseNumber='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text + " '";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
string sql1 = "update 班级课表 set college='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox6")).Text + "',class='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox7")).Text + "' where courseNumber='" + ((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text + " '";
SqlCommand cmd1=new SqlCommand (sql1,con );
cmd1.ExecuteNonQuery ();
con.Close();
Response.Write("<script language='javascript'>alert('修改成功!')</script>");
GridView2.EditIndex = -1;
this. bind();
两条语句是因为里面的信息来自不同的表! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询