/// <summary> /// fires when Delete button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteRecord(object sender, GridViewDeleteEventArgs e) { int personID = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); // instantiate BAL PersonBAL pBAL = new PersonBAL(); Person person = new Person(); try { person.PersonID = personID; pBAL.Delete(person); lblMessage.Text = "Record Deleted Successfully."; } catch (Exception ee) { lblMessage.Text = ee.Message.ToString(); } finally { person = null; pBAL = null; } GridView1.EditIndex = -1; // Refresh the list BindGrid(); }