I'm having a problem with editing values of a gridview and them being updated back to the gridview. At the moment the code gets the old value of the textbox and I'm assuming I've made an error in trying to obtain the new value.
I've highlighted what I think to be the problem.
protected void GVCheckout_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//Retrieve the table from the session object.
DataTable dt = (DataTable)Session["Cart"];
//Update the values.
GridViewRow row = gv_checkout.Rows[e.RowIndex];
[B]string quantity = ((TextBox)(gv_checkout.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString();[/B]
dt.Rows[row.DataItemIndex]["Quantity"] = int.Parse(quantity);
dt.Rows[row.DataItemIndex]["Airbrushing"] = ((CheckBox)(row.Cells[7].Controls[0])).Checked;
//Reset the edit index.
//gv_checkout.DataSource = "Cart";
//gv_checkout.DataMember = "Cart";
//gv_checkout.DataBind();
gv_checkout.EditIndex = -1;
//Bind data to the GridView control.
BindData();
}
private void BindData()
{
gv_checkout.DataSource = Session["Cart"];
gv_checkout.DataBind();
}
Thanks