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>
4

1 回答 1

0

The SQL data source

<asp:SqlDataSource ID="SqlDataSource2"

Should be outside of repeater.

于 2012-11-05T07:24:53.370 回答