public void DeleteSubDetailRow() { if (SelectedSubDetailRows != null) { var res = MessageBox.Show("Are You To Delete SelectedRecords From Database ?", "Delete", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { foreach (var row in SelectedSubDetailRows) { if (row.Iserial != 0) { if (AllowDelete != true) { MessageBox.Show(strings.AllowDeleteMsg); return; } Loading = true; Glclient.DeleteTblGlRuleDetailAsync( (TblGlRuleDetail) new TblGlRuleDetail().InjectFrom(row), 1, LoggedUserInfo.DatabasEname); } else { SelectedDetailRow.DetailsList.Remove(SelectedSubDetailRow); if (!SelectedDetailRow.DetailsList.Any()) { AddNewSubDetailRow(false); } } } } } }