GridView数据更新问题
代码如下:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string userID = this.GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string Name = ((TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtb1")).Text;
Response.Write(Name);
SqlConnection con = new SqlConnection("server=.;database=login;uid=sa;pwd=;");
con.Open();
SqlCommand cmd = new SqlCommand("update login set userName='" + Name + "' where userID='" + userID + "'", con);
cmd.ExecuteNonQuery();
this.GridView1.EditIndex = -1;
this.GridViewToBind();
}
我想实现GridView数据更新,可是老更新不过来,红色标出来的部分打印出来发现是未编辑前的数据,重新输入到文本框里的数据不能显示出来,那位知道是怎么回事???