Udało mi się stworzyć coś takiego, chociaż nie wydaje mi się, że to właśnie chcesz osiągnąć (albo nie widzę w tym większego celu):
using System;
using System.Data;
using System.Data.DataSetExtensions;
using System.Xml;
using System.Linq;
public class Program
{
public static void Main()
{
DataTable table = GetTable();
var data = table.AsEnumerable().
GroupBy(r => r.Field<int>("ID")).
Select(g => g.First(r => r.Field<int>("ilosc") == g.Max(s => s.Field<int>("ilosc")))).
CopyToDataTable();
foreach(var d in data.AsEnumerable())
{
Console.WriteLine("Id: {0}", d.Field<int>("id"));
Console.WriteLine("Nazwa: {0}", d.Field<string>("nazwa"));
Console.WriteLine("Ilosc: {0}", d.Field<int>("ilosc"));
Console.WriteLine();
}
}
static DataTable GetTable()
{
DataTable table = new DataTable();
table.Columns.Add("Id", typeof(int));
table.Columns.Add("Nazwa", typeof(string));
table.Columns.Add("Ilosc", typeof(int));
table.Rows.Add(1, "nazwa1", 10);
table.Rows.Add(2, "nazwa2", 20);
table.Rows.Add(1, "nazwa3", 30);
table.Rows.Add(3, "nazwa4", 10);
table.Rows.Add(3, "nazwa5", 40);
return table;
}
}
Wynik działania: https://dotnetfiddle.net/V5k45e