public void DeleteDetailRow() { if (SelectedDetailRows != null) { var res = MessageBox.Show("Are You To Delete SelectedRecords From Database ?", "Delete", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { var ListInt = SelectedDetailRows.Select(w => w.Iserial).ToList(); var ObsInt = new ObservableCollection <int>(); foreach (var item in ListInt) { ObsInt.Add(item); } if (AllowDelete != true) { MessageBox.Show(strings.AllowDeleteMsg); return; } Glclient.DeleteTblJournalSettingEntityAsync(ObsInt, LoggedUserInfo.DatabasEname); foreach (var row in SelectedDetailRows.Where(w => w.Iserial == 0).ToList()) { SelectedMainRow.DetailsList.Remove(row); } if (!SelectedMainRow.DetailsList.Any()) { AddNewDetailRow(false); } } } }