[英]DropDownListboxes - why is this data being added?
I have three dropdownlistboxes that are populated with "select distinct" queries and it works fine at first glance. 我有三个下拉列表框,其中填充了“选择不同的”查询,乍一看它工作正常。 Ddl1 has only one of each item from the database, and then ddl2 has only one of each item that go with what was selected in ddl1, until you change ddl1, then it adds what was in ddl2 from the first selection to the 2nd selection.
Ddl1只有数据库中每个项目中的一个,然后ddl2只有每个项目中的一个与ddl1中选择的项目一致,直到你更改ddl1,然后它将ddl2中的内容从第一个选择添加到第二个选择。
just to give further explanation of what is happening: 只是为了进一步解释发生的事情:
if the first one has A, B, C and you select A, the second one with show D, E, and F. then if you decide to go back and change the first one to B the second has G, H, I, AND it still has D, E, F, when it should only have G, H, and I 如果第一个有A,B,C并且您选择A,第二个有显示D,E和F.那么如果您决定返回并将第一个更改为B,则第二个具有G,H,I,并且它仍然有D,E,F,它应该只有G,H和I.
What am I doing wrong? 我究竟做错了什么?
Here are my datasources: 这是我的数据源:
<asp:SqlDataSource ID="LEDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AXMAPConnectionString %>" SelectCommand="SELECT DISTINCT [LegalEntity] FROM [AXMAP].[Customers]"></asp:SqlDataSource>
<asp:SqlDataSource ID="OSEDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AXMAPConnectionString %>" SelectCommand="SELECT DISTINCT [OldSourceEnvironment] FROM [AXMAP].[Customers] WHERE LegalEntity = @LegalEntity">
<SelectParameters>
<asp:ControlParameter ControlID="ddlLegalEntity" PropertyName="SelectedValue" Type="String" Name="LegalEntity" DefaultValue="-- Please Select --" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="OCCDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AXMAPConnectionString %>" SelectCommand="SELECT DISTINCT [OldCompanyCode] FROM [AXMAP].[Customers] WHERE LegalEntity = @LegalEntity AND OldSourceEnvironment = @OldSourceEnvironment">
<SelectParameters>
<asp:ControlParameter ControlID="ddlLegalEntity" PropertyName="SelectedValue" Type="String" Name="LegalEntity" DefaultValue="-- Please Select --" />
<asp:ControlParameter ControlID="ddlOldSourceEnvironment" PropertyName="SelectedValue" Type="String" Name="OldSourceEnvironment" DefaultValue="-- Please Select --" />
</SelectParameters>
</asp:SqlDataSource>
And Here are my dropdownlists: 以下是我的下拉列表:
<td class="auto-style6">
<asp:DropDownList ID="ddlLegalEntity" runat="server" AutoPostBack="True" DataSourceID="LEDataSource" DataTextField="LegalEntity" DataValueField="LegalEntity" Width="135px" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="0" Text="-- Please Select --"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style6">
<asp:DropDownList ID="ddlOldSourceEnvironment" runat="server" AutoPostBack="true" DataSourceID="OSEDataSource" DataTextField="OldSourceEnvironment" DataValueField="OldSourceEnvironment" AppendDataBoundItems="true" Width="135px">
<asp:ListItem Selected="True" Value="0" Text="-- Please Select --"></asp:ListItem>
</asp:DropDownList>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style6">
<asp:DropDownList ID="ddlOldCompanyCode" runat="server" AutoPostBack="true" DataSourceID="OCCDataSource" DataTextField="OldCompanyCode" DataValueField="OldCompanyCode" AppendDataBoundItems="true" Width="135px">
<asp:ListItem Selected="True" Value="0" Text="-- Please Select --"></asp:ListItem>
</asp:DropDownList>
你已经设定好了
AppendDataBoundItems="true"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.