Grouping relevant data together while iterating throug them
-
Hi There, I would like to know if someone can assist me with the following: I need to display data in a tabular format, but I would like to group the relevant data together. In the sample below I am using a asp:repeater to populate a table. The select statement in my code behind file would return data from different employees within different companies ordered by the company name. I want to group all employees from one company together and do a basic summary line before starting with the next company i.e. Number of employees found per company.
<asp:repeater id="employeeList" Runat="server"> <HeaderTemplate> <tr> <td width="200"> Company ID </td> <td width="200"> First Name </td> <td width="200"> Last Name </td> <td width="200"> Company </td> </tr> </HeaderTemplate> <ItemTemplate> <tr bgcolor="#ccffff" style="FONT-SIZE: 12px; COLOR: red"> <td><%# DataBinder.Eval(Container.DataItem,"COID") %></td> <td><%# DataBinder.Eval(Container.DataItem,"FIRSTNAME") %></td> <td><%# DataBinder.Eval(Container.DataItem,"LASTNAME") %></td> <td><%# DataBinder.Eval(Container.DataItem,"COMPANY") %></td> </tr> </ItemTemplate> <FooterTemplate> </FooterTemplate> </asp:repeater>