我在GRIDVIEW 里面点更新时为什么取的不是我手动输入文本框的值是最初加载GridView的值??代码如下:
难道我写错了?
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
         string strID = GridView1.Rows[e.RowIndex].Cells[0].Text;
         int sID=Convert.ToInt32(strID);
        string strName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
        string strPos = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
        string strEmail = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
        string strMob = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
        string strPho = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text;
        string strQQ = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text;
        string strMsn = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[7].Controls[0]).Text;

解决方案 »

  1.   

    EmployeTableAdapter emp = new EmployeTableAdapter();
            这是更新的方法 emp.UpdateQuery(strName, nDepID, strPos, strEmail, strMob, strPho, strQQ, strMsn, strState, CmpID, sID);
            
            GridView1.EditIndex = -1;
            GridView1.DataBind();
      

  2.   

    page_load中绑定加上if(!this.IsPostBack)
    {
        //然后绑定
    }
      

  3.   

    yes,在Page_Load事件中添加if(!Page.IsPostBack)
    {
       数据绑定
    }
      

  4.   

    把gridiview绑定放在if(!ispostback){}里面
      

  5.   

    babyrockxray(紫色阴影) ( )
    同我一样,回答两个不同的问题,答案都一样.
      

  6.   

    哦原来..我直接在Page_Load里面写的帮定没加ispostback