我每次都有中继器的问题。我想在我的数据库中重复一个独特类别下的设备列表。类别名称重复,但设备名称重复所有类别(意味着所有类别都具有相同的设备)我使用嵌套转发器为设备我不知道这是否是问题。
<%@ 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>
</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">
<asp:TextBox ID="kwh" runat="server" CssClass="input4" Width="59px"></asp:TextBox>
</div></td>
<td><div align="center">
<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>
kWh; <br /></td>
</tr>
<tr>
<td class="highlight"><font color="#9f7f40">Estimated</font> monthly <u><font color="#FF0000">household</font></u>*
bill: ¢
<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 :(得分:0)
SQL数据源
<asp:SqlDataSource ID="SqlDataSource2"
应该在转发器之外。