private void btnDelete_Click(object sender, EventArgs e) { //get the ID from an application S.ID = Convert.ToInt32(txtID.Text); bool success = S.DeleteSession(S); if (success == true) { MessageBox.Show("Successfully Deleted."); //refresh the gridview DataTable dt = S.Select(); dataGridView1.DataSource = dt; Clear(); } else { MessageBox.Show("Failed to Delete.Try Again."); } }