我没那多分哎! 以后卖身给
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
// 点更新处理事件
{
    string str = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
// 比如说在这行的某个编辑框里输入新值, 点更新后调用这个事件,我要得到这个编辑筐的行值,可是/为什么是以前的呢
this.dataSet.Tables["user_info"].Rows[e.Item.ItemIndex][2] = str;
this.dataSet.AcceptChanges();
this.dataAdapter.Update(dataSet,"user_info");
this.DataGrid1.EditItemIndex = -1;
this.DataGrid1.DataSource = dataSet.Tables["user_info"];
this.DataGrid1.DataBind();
}
结果是根本不能更新,还是本来的值

解决方案 »

  1.   

    try
    {
    string update="update ClassStu set 姓名='";
    where 学号=";update+=this.textBox学号.Text+" ;
    this.sqlCommand1.CommandText =update;
    this.sqlCommand1.Connection=this.strCon;
    this.strCon.Open ();
    this.sqlCommand1.ExecuteNonQuery ();
    this.strCon.Close ();
    this.mydataSet1.Clear ();
    this.mydataAdapter.Fill (this.mydataSet1,"ClassStu");
    // this.dataGrid1 .CurrentRowIndex =this.mydataSet1.Tables ["ClassStu"].Rows .Count-1;
    MessageBox.Show ("修改数据成功!","Information",MessageBoxButtons.OK ,MessageBoxIcon.Information );}
    catch(Exception error)
    {
    MessageBox.Show ("修改信息发生错误:"+ error.Message ,"提示",MessageBoxButtons.OK ,MessageBoxIcon.Information );
    if(this.strCon.State==ConnectionState.Open )
    {
    this.strCon.Close ();
    }
    }
      

  2.   

    楼上的,我要的是直接通过dataset~~~~~~``
      

  3.   

    或者是你this.dataAdapter没有更新Command,且你的DataSet的名字和数据库中表的名字不一致。不过个人觉得出于性能考虑,最好不要用Adapter来更新数据库。
      

  4.   

    反啦
    this.dataAdapter.Update(dataSet,"user_info");
    this.dataSet.AcceptChanges();
      

  5.   

    取TextBox有错,试试
    DataGridItem  item = (DataGridItem)((Button)source).Parent.Parent;
    TextBox tb = (TextBox)item.FindControl("txtNewReply");
      

  6.   

    string str = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
    改为:
    string str = ((TextBox)e.Item.FindControl("你的文件框ID")).Text.Trim();
      

  7.   

    是不是你的page_load绑定了datagrid ?
    应该加
    if(!Page.IsPostBack)
    {
    }
    ======================================================
    欢迎加入群:13817403
    本人大四,这学期找工作了,各位兄弟帮帮忙
    我的简历:http://sme.dlut.org/winal/introduce.aspx
    ======================================================