Click here to Skip to main content
15,885,213 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a linq query,
SQL
var j=from o in Orders
       join  OT in OrderDetails on o.OrderId equals OT.OrderId
       group OT.ProductId by o.OrderId into g
      select new{OrderId=g.Key,ProductId=g};

j.Dump();

It returns the data as,
XML
5IOrderedQueryable<> (4 items)4
OrderId ProductId
13 Key= 13
5IGrouping<Int32,Int32> (2 items)4
32
40

14 Key= 14
5IGrouping<Int32,Int32> (3 items)4
39
48
49

15 Key= 15
5IGrouping<Int32,Int32> (2 items)4
43
30

16 Key= 16
5IGrouping<Int32,Int32> (3 items)4
43
48
49

---
I binded this query to gridview as ,
SQL
var j = (from o in con.Orders
        join OT in con.OrderDetails on o.OrderId equals OT.OrderId
        group OT.ProductId by o.OrderId into g

         select new { OrderId = g.Key, ProductId = g }).ToList();
gridview.DataSource = j;
gridview.DataBind();

like this, but whe i execute i got gridview displaying like this,

Order Id Product Id
13 System.Data.Entity.Core.Objects.ELinq.InitializerMetadata+Grouping`2[System.Int32,System.Int32]
14 System.Data.Entity.Core.Objects.ELinq.InitializerMetadata+Grouping`2[System.Int32,System.Int32]
15 System.Data.Entity.Core.Objects.ELinq.InitializerMetadata+Grouping`2[System.Int32,System.Int32]
16 System.Data.Entity.Core.Objects.ELinq.InitializerMetadata+Grouping`2[System.Int32,System.Int32]

how to make gridview to display like this i want,

OrderId ProductId
13 32
40
14 39
48
49
15 43
30
16 43
48
49
like this , pls help me
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900