Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve old value from textbox (Gridview) 1

Status
Not open for further replies.

aspvbnetnerd

Programmer
May 16, 2006
278
SE
I am trying to get a value from gridview when trying update a row.

I press edit on the gridview and then type som new information on the textbox and then click update.

On RowUpdating I am trying to catch to the new value that I has entered and then click update.
But I am getting the old text in my string dFName and not the new entered text

Code:
protected void GridProjects_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

    System.Web.UI.WebControls.TextBox FieldName2 = new System.Web.UI.WebControls.TextBox();
    FieldName2 = ((TextBox)(this.GridProjects.Rows[e.RowIndex].Cells[10].Controls[0]));
    string dFName = FieldName2.Text;

}

Any help is appreciated

/George
 
ca8msm, added the check for a posback and it worked like a charm. Thank you

Code:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        initData();
    }
}

void initData()
{

    mDataAdapter = new DataAdapter();
    mDataAdapter.init(mConnectionString);

    SqlDr = mDataAdapter.getProjects();

    GridProjects.DataSource = SqlDr;
    GridProjects.DataBind();

    //clean up
    SqlDr.Close();
    SqlDr = null;
    mDataAdapter.dispose();
    mDataAdapter = null;

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top