protected void update(object sender, GridViewUpdateEventArgs e) { try { CPT_AccountMaster accountdetails = new CPT_AccountMaster(); int id = int.Parse(gvAccount.DataKeys[e.RowIndex].Value.ToString()); accountdetails.AccountMasterID = id; string accountName = ((TextBox)gvAccount.Rows[e.RowIndex].Cells[2].Controls[0]).Text; accountdetails.AccountName = accountName; AccountMasterBL updateAccount = new AccountMasterBL(); updateAccount.Update(accountdetails); gvAccount.EditIndex = -1; BindGrid(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }