Many ways to do this..
You could sort the DataGridView by name and then iterate over it to look for duplicate names.
Or you could read the data into a Dictionary like this:
Dictionary<string, List<int>> data = new Dictionary<string,List<int>>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string name = row.Cells[1].ToString();
int ID = Convert.ToInt32(row.Cells[0]);
if (data.ContainsKey(name)) data[name].Add(ID);
else data.Add(name, new List<int>(new int[] { ID }));
}
foreach (string name in data.Keys)
if (data[name].Count > 1 )
{
Console.Write(name);
foreach (int ID in data[name]) Console.Write(ID.ToString("##### "));
Console.WriteLine();
}
Or you could wait for someone with a cute LINQ solution..