//delete a task according task id private void deleteTask_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want to delete this recode?", "Alert", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (checkTaskID()) { String txtTaskID = taskID.Text.Trim(); TaskManagement taskMgt = new TaskManagement(); taskMgt.DeleteTask(Int32.Parse(txtTaskID)); isLoading = true; PopulateTasks(false); isLoading = false; datagridTask.Items.Refresh(); } } }