Удаление повторяющихся значений столбцов таблицы данных
I have a datatable like below: Name Department John Alter D01 Prakash Kiran D01 Steffy Cold D01 Julia Roberts D02 Candy Mitchel D02 Monika Diesel D03 I want it like below: Name Department John Alter D01 Prakash Kiran Steffy Cold Julia Roberts D02 Candy Mitchel Monika Diesel D03 when its ordered by a department, it should not repeat for the same department. But the row should be there, only if there is same value in next row under Department column, that needs to be BLANK help ASAP
Что я уже пробовал:
Used the below code from someone.. but its not working
DataTable newDt = dt.Clone(); for (int i = 0; i < dt.Rows.Count; i++) { DataRow newRow = newDt.NewRow(); newRow["Name"] = dt.Rows[i]["Name"]; int originalIndex = dt.AsEnumerable().ToList().FindIndex(x => x["Department"] == dt.Rows[i]["Department"]); if (originalIndex < i) { newRow["Department"] = ""; } else { newRow["Department"] = dt.Rows[i]["Department"]; } newDt.Rows.Add(newRow); }