2012-11-04 94 views
1

我有一些麻煩,每個中繼器。我正在嘗試在我的數據庫的獨特類別下重複使用設備列表。類別名稱重複好吧,但該設備的名稱重複所有類別(即所有類別具有相同的電器)我使用嵌套中繼器的家電,我不知道這是否是問題。嵌套中繼器

<%@ Page Title="" Language="VB" MasterPageFile="~/public.master" AutoEventWireup="false" CodeFile="ccalc.aspx.vb" Inherits="ccalc" %> 

<%@ Import Namespace="System.Data" %> 

<%@ Import Namespace="System.Data.OleDb" %> 

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"> 

    <div> 
    <h1>Estimated Monthly Electricity Consumption Calculator</h1> 
</div> 
<div> 


       <asp:Repeater ID="myRepeater" runat="server"> 
         <ItemTemplate> 
         <table width="100%" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF" class="ten"> 
         <tbody>       
         <tr> 
          <td colspan="5"><h2> 
           <asp:Label ID="catid" runat="server" Text='<%#Eval("CategoryID") %>'></asp:Label> 
           <asp:Label ID="Catname" runat="server" Text='<%#Eval ("CategoryName") %>'></asp:Label></h2> 
          </td> 
         </tr> 
         <tr align="center"> 
          <th class="style1" bgcolor="#FFCC66">Electrically Powered Items</th> 
          <th class="ten" bgcolor="#FFCC66"><div align="center">Quantity</div></th> 
          <th class="ten" bgcolor="#FFCC66"><div align="center">Average 
          monthly KWh</div></th> 
          <th class="ten" bgcolor="#FFCC66"><div align="center">KWh/month</div></th> 
          <th class="ten" bgcolor="#FFCC66"><div align="center">GHc /month</div></th> 
         </tr> 



          <asp:Repeater ID="innerRepeater" runat="server" DataSource = <%# sqldatasource3%> > 
          <ItemTemplate > 
         <tr> 
          <td class="style1"><strong> 
           <asp:Label ID="appName" runat="server" Text='<%#Eval ("ApplianceName") %>'></asp:Label></strong></td> 
          <td class="highlight"><div align="center"> 

           <asp:TextBox ID="quantity" runat="server" AutoPostBack="True" CssClass="input" 
            Width="79px" ></asp:TextBox> 
           &nbsp;&nbsp;</div></td> 
          <td><div align="center"> 
          <input name="refrigeratorMonthKWh" value="182" type="hidden" /> 
           <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
          </div></td> 
          <td><div align="center"> 
           &nbsp;<asp:TextBox ID="kwh" runat="server" CssClass="input4" Width="59px"></asp:TextBox> 
          </div></td> 
          <td><div align="center"> 
           &nbsp;<asp:TextBox ID="ghc" runat="server" CssClass="input4" Width="59px"></asp:TextBox> 
          </div></td> 
         </tr> 
         </ItemTemplate> 
          </asp:Repeater> 

         <% 

          'End While 
          'brb.Dispose() 
          'br.Close() 


          %> 


         </tbody> 

        </table> 
        </ItemTemplate> 
         </asp:Repeater> 

        <% 




         'End While 
         'cmd.Dispose() 
         'dr.Close() 

         %> 


</div> 
    <% 

    %> 
<div> 

<table width="100%" border="0" cellpadding="5" bgcolor="#FFF7E5" class="ten"> 
         <tbody> 
         <tr> 
          <td><font color="#9f7f40">Estimated</font> monthly <u><font color="#FF0000">household </font></u>* 
          usage: 
           <asp:TextBox ID="totalusage" runat="server" CssClass="input4" Width="59px"></asp:TextBox> 
&nbsp;kWh; <br /></td> 
         </tr> 
         <tr> 
          <td class="highlight"><font color="#9f7f40">Estimated</font> monthly <u><font color="#FF0000">household</font></u>* 
          bill: &cent; 
                <asp:TextBox ID="totalbill" runat="server" 
            CssClass="input4" Width="59px"></asp:TextBox> 
           <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>" 
            SelectCommand="SELECT * FROM [DeviceCategory]"></asp:SqlDataSource> 
           <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>" 
            SelectCommand="SELECT * FROM [Appliances] where ([CategoryID]=[CategoryID])"> 
            <%--<SelectParameters> 
            <asp:ControlParameter ControlID=myRepeater.innerrepeater.catid Name="catid" PropertyName="Text" 
             Type="String" /> 
            </SelectParameters>--%> 
            </asp:SqlDataSource> 
          </td> 
         </tr> 
         <tr> 
          <td class="highlight"><h3><strong><em>*Heating usage 
          not included in household totals</em></strong></h3></td> 
         </tr> 
         </tbody> 
        </table> 

</div> 


</asp:Content> 
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 
</asp:Content> 
+0

沒有它不有所作爲我的問題是通過控制值作爲嵌套中繼器中的SELECT查詢參數中。 – GolDRoger

回答

0

該SQL數據源

<asp:SqlDataSource ID="SqlDataSource2" 

應該是中繼器的外部。

+0

對不起,我應該把它解決掉。對於外部中繼器的數據源是sqldatasource1和內部數據源是sqldatasource2 – GolDRoger

+0

沒有它的工作取出後如預期? –