I have a table (data retrieved from an SQL database) in the form:
βββββββββ¦βββββββββββββββ β Model β Manufacturer β β ββββββββ¬βββββββββββββββ£ β A β 1 β β
Each row is its own <tr> when I bind data to <asp:datagrid> . However, I need:
βββββββββ¦βββββββββββββββ β Model β Manufacturer β β ββββββββ¬βββββββββββββββ£ β A β 1 β β β 2 β β β 3 β β
I spent a lot of time searching and tried several different things, most of which used LINQ. But my knowledge and understanding of LINQ is very small. I think (but I could be completely wrong), the closest I came from this question / answer: Linq query to combine the results of a cellular network? . My slightly modified version:
Dim results = table.AsEnumerable().GroupBy(Function(x) x.Field(Of String)("Model")).[Select](Function(grouping) New With { .Key = grouping.Key, .CombinedModel = grouping.Aggregate(Function(a, b) a + " " + b) }).[Select](Function(x) New ModelRecord() With { .Manufacturer = x.Key.Manufacturer, .Model = x.CombinedModel })
But due to a lack of knowledge of LINQ, I donβt understand the "definition of a specific type to represent Row " (which creates a problem with ModelRecord() in my code).
At that moment, I was almost completely lost. Am I complicating things too much? Is this really wrong? Any help here would be greatly appreciated.
source share