新手求教 GridView 的 RowUpdating 失效?????
//我的RowUpdating模块,事件触发都有为啥就是获得不了修改过的数据呢????protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{ string id = GridView1.Datakeys[e.RowIndex].Value.ToString();//能获得行号
string name = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();//修改后执行与原数据一样
string local = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();//修改后执行与原数据一样
string sqlStr = "update t_user set fname='"+name+"',flocal='"+local+"' where fid="+id;
SqlConnection myConn = GetConnection();//自定义数据连接方法
myConn.Open();
SqlCommand myCmd = new SqlCommand(sqlStr,myConn);
myCmd.ExecuteNonQuery();
myCmd.Dispose();
myConn.Close();
GridView1.EditIndex = -1;
GridViewBind();//自定义数据绑定页面
}