protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { clsDBaccess dbobj = new clsDBaccess(); try { int rowupdate = e.RowIndex; String txtCarNo = (String)GridView1.Rows[rowupdate].Cells[1].Text; //TextBox txtCarCat = (TextBox)GridView1.Rows[rowupdate].Cells[2].Controls[0]; /* TextBox txtCarName = (TextBox)GridView1.Rows[rowupdate].Cells[3].Controls[0]; * * TextBox txtCarType = (TextBox)GridView1.Rows[rowupdate].Cells[4].Controls[0]; * TextBox txtFuelType = (TextBox)GridView1.Rows[rowupdate].Cells[5].Controls[0]; * TextBox txtDescription = (TextBox)GridView1.Rows[rowupdate].Cells[6].Controls[0]; * TextBox txtHrlyRate = (TextBox)GridView1.Rows[rowupdate].Cells[7].Controls[0]; * TextBox txtMinHrs = (TextBox)GridView1.Rows[rowupdate].Cells[8].Controls[0];*/ TextBox txtbooked = (TextBox)GridView1.Rows[rowupdate].Cells[9].Controls[0]; // String password = (String)GridView1.Rows[rowupdate].Cells[5].Text; String query = "update tblcar set Booked='" + txtbooked.Text + "' where CarNo='" + txtCarNo + "'"; dbobj.InsertUpdateDelete(query); //remove the edit mode GridView1.EditIndex = -1; populateGridview(); } catch (Exception err) { lblmsg.Text = err.Message; } }