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