gridview无法更新,已经开了3贴了
代码如下
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
OracleConnection conn = new OracleConnection( "Data Source=xx;User ID=xx;Password=xx; ");
string strSQL = "update UNIT set UNIT_ID= ' "
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim() + " ',UNITID= ' "
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + " ',UNAME= ' "
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim() + " ',UCHIEF= ' "
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + " ',POST= ' "
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + " ',PHONE= ' "
+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim() + " ' where UNIT_ID= ' "
+ GridView1.DataKeys[e.RowIndex].Value.ToString() + " ' ";
OracleCommand cmd = new OracleCommand(strSQL, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
GridView1.EditIndex = -1;
GV1();
}
if (!IsPostBack)处已经重新绑定了,现在的问题是string strSQL = "update 断点跟踪发现取到的值不是更新后的值
------解决方案--------------------
UNIT_ID在数据库什么类型的
GridView1是否设置了DataKeyNames属性