//Get the UserName to be deleted from the form string sUserName = Request.Form.Get("TextBoxUserName"); //see if the user already exists in the database DataTable dt = ds.Tables[0]; string sFilter = "UserName = \'" + sUserName + "\'"; DataRow[] drUserToDelete = dt.Select(sFilter); if (drUserToDelete.Length == 0) { LabelFeedback.Text = "The username " + sUserName + " does not exist. It was therefore not deleted."; } else { //Delete the user DataRow dr = drUserToDelete[0]; dr.Delete(); //Update the database dataAdapter.Update(ds); //Write a success message LabelFeedback.Text = "The user name " + sUserName + " has been deleted."; //Update the Listbox PopulateListBox(); ListBoxUsers.SelectedIndex = 0; PopulateFieldsForSelectedUser(); }