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>
Regards, -
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>
Regards,Hi, If your data is stored in XML format, you could use XSLT to achieve this. Just in case you are unaware of XSLT, XSLT is an XML based transform language which lets you sort, present, and summarize data which is stored within an XML file. Here is a useful link for getting started: http://www.xml.com/pub/a/2000/08/holman/index.html?page=1[^] I hope that this is of use! Lea Hayes