private void dgvDuplicated_SelectionChanged(object sender, EventArgs e) { dgvDuplicates.Rows.Clear(); if (dgvDuplicated.CurrentRow != null) { var selectedRow = dgvDuplicated.CurrentRow; var matchingKey = selectedRow.Cells["key"].Value != null ? selectedRow.Cells["key"].Value.ToString() : string.Empty; if (!string.IsNullOrEmpty(matchingKey)) { var duplicates = _duplicated[matchingKey]; foreach (var item in duplicates) { var rowIndex = dgvDuplicates.Rows.Add(); var row = dgvDuplicates.Rows[rowIndex]; foreach (DataGridViewColumn col in dgvDuplicates.Columns) { var attr = col.Name; row.Cells[attr].Value = GetAttributeDisplayValue(item, attr); } var url = CrmHelper.BuildRecordUrl(this.ConnectionDetail.WebApplicationUrl, _entities[item.LogicalName].ObjectTypeCode.Value, item.Id); row.Cells["hiddenurl"].Value = url; } } } }
private void dgvDuplicated_SelectionChanged(object sender, EventArgs e) { dgvDuplicates.Rows.Clear(); if (dgvDuplicated.CurrentRow != null && dgvDuplicated.SelectedRows.Count == 1) { var selectedRow = dgvDuplicated.CurrentRow; var matchingKey = selectedRow.Cells["key"].Value != null ? selectedRow.Cells["key"].Value.ToString() : string.Empty; if (!string.IsNullOrEmpty(matchingKey)) { var duplicates = _dataProcessor.GetDuplicates(matchingKey); foreach (var item in duplicates) { var entity = item as IDictionary <string, object>; var rowIndex = dgvDuplicates.Rows.Add(); var row = dgvDuplicates.Rows[rowIndex]; foreach (DataGridViewColumn col in dgvDuplicates.Columns) { var attr = col.Name; if (entity.ContainsKey(attr)) { row.Cells[attr].Value = entity[attr]; } } var url = CrmHelper.BuildRecordUrl(this.ConnectionDetail.WebApplicationUrl, _entities[_dataProcessor.Config.TargetEntity].ObjectTypeCode.Value, (Guid)entity["Id"]); row.Cells["hiddenurl"].Value = url; } } } }