C# – RowUpdating GridView Showing Old value

asp.netcgridview

enter image description here

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridView1.EditIndex = e.NewEditIndex;
    GridView1.DataBind();

}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
    GridView1.EditIndex = -1;
    GridView1.DataBind();
}

Row editing and Row canceling editing working fine; but when I press update after changing the value in textbox, it show the old value not that value that I have change.The following is Row updating event code.

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

dao.AridNumber = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
dao.FirstName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
dao.LastName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;

}

update me!

Best Answer

I think you need to bind the data again at the last of the method inorder to show you the appropriate result.

Hope this Helps!!

Related Topic