protected void btnDelete_Click(object sender, EventArgs e) { try { UserDetail ud = new UserDetail(); ud.DeleteStudent(txtStudentID.Text); lblMessage.Text = "Successfully Deleted!"; txtStudentID.Text = ""; txtStudentName.Text = ""; txtRollNumber.Text = ""; txtUsername.Text = ""; txtEmail.Text = ""; txtStudentID.Focus(); } catch (Exception) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Record Cannot be Deleted"; } }