Multi-level classified statistics List Implementation

Source: Internet
Author: User

Because the school's train booking system requires statistics of the number of votes and money of the school class. Shows the implementation list. Go straight to the topic below.

Part of the aspx page code:

 
 
  1. <Asp: SqlDataSource ID = "SqlDataSource1" runat = "server"
  2. ConnectionString = "<% $ ConnectionStrings: TrainConnectionString %>">
  3. </Asp: SqlDataSource>
  4. <Div style = "color: #4C4847; font-size: 16px; margin: 0 auto; text-align: center; padding: 10px; font-weight: bold;">
  5.  
  6. Fuzhou University train ticket booking system-ticket booking schedule <% = DateTime. Now. tow.datestring () %>) </div>
  7. <Asp: ListView ID = "lsvAcademe" runat = "server" performanceid = "sqlperformance1" DataKeyNames = "AcademeID">
  8. <EmptyDataTemplate>
  9. <Div style = "color: red; font-size: 16px; margin: 0 auto; text-align: center;"> sorry, no data is found! </Div>
  10. </EmptyDataTemplate>
  11. <LayoutTemplate>
  12. <Table class = "order-list-table">
  13. <Tr>
  14. <Th> school </th> <th> Number of votes </th> <th> total hard seat price </th> <th> pre-paid total price </th>
  15. <Th> class </th> <th> Number of votes </th> <th> total hard seat price </th> <th> pre-paid total price </th>
  16. <Tr>
  17. <Asp: PlaceHolder ID = "itemPlaceHolder" runat = "server"> </asp: PlaceHolder>
  18. <Td colspan = "8" style = "height: 0;"> </td>
  19. </Tr>
  20. </Table>
  21. </LayoutTemplate>
  22. <ItemTemplate>
  23. <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # Eval ("Academe") %> </td>
  24. <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # Eval ("TicketCount") %> </td>
  25. <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # String. format ("{0: 0. 0} ", Eval (" HardseatTotal ") %> </td>
  26. <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # String. format ("{0: 0. 0} ", Eval (" AdvanceTotal ") %> </td>
  27. <Uc1: ListViewClass ID = "ListViewClass1" runat = "server" AcademeID = '<% # Eval ("AcademeID") %>'/>
  28. </ItemTemplate>
  29. </Asp: ListView> \

I used the nesting of the Listview control, but I separated it into an independent user control.
Control display code:

 
 
  1. <asp:ListView runat="server" ID="lsvClass" DataSourceID="SqlDataSource1"> 
  2.             <LayoutTemplate>                 
  3.                 <asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder> 
  4.             </LayoutTemplate> 
  5.             <ItemTemplate> 
  6.                 <td><%#Eval("ClassName") %></td> 
  7.                 <td><%#Eval("TicketCount") %></td> 
  8.                 <td><%#String.Format("{0:0.0}",Eval("HardSeatTotal")) %></td> 
  9.                 <td><%#String.Format("{0:0.0}",Eval("AdvanceTotal")) %></td></tr><tr>                  
  10.             </ItemTemplate> 
  11. </asp:ListView> 
  12. <asp:SqlDataSource ID="SqlDataSource1" runat="server"   
  13.     ConnectionString="<%$ ConnectionStrings:TrainConnectionString %>"   
  14.     SelectCommand="SELECT * FROM [V_DetailOrderListForClass]"></asp:SqlDataSource> 
  15.  

Control's cs Page code:

 
 
  1. namespace Website.Controls  
  2. {  
  3.     public partial class ListViewClass : System.Web.UI.UserControl  
  4.     {  
  5.         private string academeID;  
  6.         public string AcademeID  
  7.         {  
  8.             set { academeID = value; }  
  9.         }  
  10.         protected void Page_Load(object sender, EventArgs e)  
  11.         {  
  12.             SqlDataSource1.SelectCommand = "SELECT * From [V_DetailOrderListForClass] where AcademeID=@AcademeID";  
  13.             SqlDataSource1.SelectParameters.Add("AcademeID",System.TypeCode.Int32, academeID);  
  14.             lsvClass.DataBind();  
  15.         }  
  16.     }  

This time, the train ticket booking system has frequently combined queries between multiple tables. Some even query multiple views to achieve a certain statistical function.) I think this performance consumption is quite high.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.