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:
- <Asp: SqlDataSource ID = "SqlDataSource1" runat = "server"
- ConnectionString = "<% $ ConnectionStrings: TrainConnectionString %>">
- </Asp: SqlDataSource>
- <Div style = "color: #4C4847; font-size: 16px; margin: 0 auto; text-align: center; padding: 10px; font-weight: bold;">
-
- Fuzhou University train ticket booking system-ticket booking schedule <% = DateTime. Now. tow.datestring () %>) </div>
- <Asp: ListView ID = "lsvAcademe" runat = "server" performanceid = "sqlperformance1" DataKeyNames = "AcademeID">
- <EmptyDataTemplate>
- <Div style = "color: red; font-size: 16px; margin: 0 auto; text-align: center;"> sorry, no data is found! </Div>
- </EmptyDataTemplate>
- <LayoutTemplate>
- <Table class = "order-list-table">
- <Tr>
- <Th> school </th> <th> Number of votes </th> <th> total hard seat price </th> <th> pre-paid total price </th>
- <Th> class </th> <th> Number of votes </th> <th> total hard seat price </th> <th> pre-paid total price </th>
- <Tr>
- <Asp: PlaceHolder ID = "itemPlaceHolder" runat = "server"> </asp: PlaceHolder>
- <Td colspan = "8" style = "height: 0;"> </td>
- </Tr>
- </Table>
- </LayoutTemplate>
- <ItemTemplate>
- <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # Eval ("Academe") %> </td>
- <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # Eval ("TicketCount") %> </td>
- <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # String. format ("{0: 0. 0} ", Eval (" HardseatTotal ") %> </td>
- <Td rowspan = '<% # Eval ("ClassCount") %>'> <% # String. format ("{0: 0. 0} ", Eval (" AdvanceTotal ") %> </td>
- <Uc1: ListViewClass ID = "ListViewClass1" runat = "server" AcademeID = '<% # Eval ("AcademeID") %>'/>
- </ItemTemplate>
- </Asp: ListView> \
I used the nesting of the Listview control, but I separated it into an independent user control.
Control display code:
- <asp:ListView runat="server" ID="lsvClass" DataSourceID="SqlDataSource1">
- <LayoutTemplate>
- <asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
- </LayoutTemplate>
- <ItemTemplate>
- <td><%#Eval("ClassName") %></td>
- <td><%#Eval("TicketCount") %></td>
- <td><%#String.Format("{0:0.0}",Eval("HardSeatTotal")) %></td>
- <td><%#String.Format("{0:0.0}",Eval("AdvanceTotal")) %></td></tr><tr>
- </ItemTemplate>
- </asp:ListView>
- <asp:SqlDataSource ID="SqlDataSource1" runat="server"
- ConnectionString="<%$ ConnectionStrings:TrainConnectionString %>"
- SelectCommand="SELECT * FROM [V_DetailOrderListForClass]"></asp:SqlDataSource>
-
Control's cs Page code:
- namespace Website.Controls
- {
- public partial class ListViewClass : System.Web.UI.UserControl
- {
- private string academeID;
- public string AcademeID
- {
- set { academeID = value; }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- SqlDataSource1.SelectCommand = "SELECT * From [V_DetailOrderListForClass] where AcademeID=@AcademeID";
- SqlDataSource1.SelectParameters.Add("AcademeID",System.TypeCode.Int32, academeID);
- lsvClass.DataBind();
- }
- }
- }
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.