tags:

views:

45

answers:

1

I am filling a datatable in my windows application. The data table looks like this

date           product
aug 2010       ABC-1
aug 2010       XYZ-1
aug 2010       MNO-2
aug 2010       WOR-4
sep 2010       XYZ-2
sep 2010       RES-3
sep 2010       WOR-4

I want to display a message box in this format

aug 2010 - ABC-1,XYZ-1........
sep 2010 - XYZ-2,RES-3.........

Only the first 2 products for each month should be displayed rest should be truncated for each month.

I hope I have explained my problem clearly.

+1  A: 
from dp in DateProducts
group dp.Product on dp.Date in g
select
{
    g.Key.ToString() 
          + " - " 
          + String.Join(",", g.Take(2).ToArray()) 
          + g.Count() > 2 ? "......." : ""
}
James Curran
hi, iam working on 2.0 framework.Is there any other way that i can do it
dude_123