Protected Sub grdview_gbb1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles grdview_gbb1.RowUpdating                Dim gvr As GridViewRow = Me.grdview_gbb1.Rows(e.RowIndex)
                Dim j As TextBox = CType(gvr.Cells(2).Controls(0), TextBox)
                dim i as string=j.text.trim()                这里放上我的更新存储过程
                End Sub问题:总是显示gridview中原始值,就算是更改了textbox中的值,也不管事,变量i总是gridview中原始值,不知何故?我都弄了好几天了,也没有弄明白为什么,求解药???!!!
网上流行下列代码,据说可以,但我用的是VB.net,不是C#,但我已经转换了,应该没有问题啦!
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow gvr = this.GridView1.Rows[e.RowIndex];
        TextBox txt1 = (TextBox)gvr.Cells[1].Controls[0];     
        TextBox txt2 = (TextBox)gvr.Cells[2].Controls[0];
        TextBox txt3 = (TextBox)gvr.Cells[3].Controls[0];        string UpdateStr = "update table set cell1='" + txt1.Text.Trim()
            + "',cell2='" + txt2.Text.Trim()
            + "',cell3='" + txt3.Text.Trim()
            + "' where id=" + this.GridView1.DataKeys[e.RowIndex].Value;
        try
        {
            mycon.myExecuteNonQuery(UpdateStr);       //自己写一个方法
            Response.Write("<script language='javascript'>alert('修改成功!');</script>");
        }
        catch (Exception exp)
        {
            Response.Write("<script language='javascript'>alert('" + exp.Message + "');</script>");
        }
        finally
        {
            this.GridView1.EditIndex = -1;
            BindData();      //自定义绑定
        }
    }