简体   繁体   English

DropDownListboxes - 为什么要添加这些数据?

[英]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>&nbsp;</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.

相关问题 为什么要添加新项目? - Why is a new item being added? 为什么不添加这些表单元格? - Why are these table cells not being added? 为什么只将第一个RadioButton添加到GroupBox? - Why is only the first RadioButton being added to the GroupBox? 为什么这些值未添加到PlayerPrefs文件中? - Why are the values not being added to the PlayerPrefs file? 正在添加数据行,但我的表中没有数据,需要if语句来停止此操作吗? - Data rows are being added with no data in my table, need a if statement to stop this? 为什么不将新行添加到我的数据库表中? - Why isn't the new row being added to my database table? 模型状态有效,并且显示成功消息,但没有数据添加到数据库中 - Model State is valid and success message displaying but no data being added to the database 数据访问项目dll未添加到客户端bin文件夹中 - Data Access project dll is not being added to the client bin folder 为什么在 XML 序列化期间将命名空间添加到子节点? - Why is the namespace being added to a child node during XML serialization? 为什么在C#中通过引用添加字典元素? - Why are dictionary elements being added by reference in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM