views:

129

answers:

0

Basically, I have four asp:DropDownLists and I wish to populate all of them from the same table, with certain conditions.
For example, I have this data source:

<asp:SqlDataSource ID="ReferenceDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:mrapConnectionString1 %>
    SelectCommand="SELECT * FROM [reference_data] WHERE ([component] = @component)" >
    <SelectParameters>
        <asp:Parameter DefaultValue="MB" Name="component" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

And I want to know if I can change that component parameter to be different for each of my four dropdown lists.
I tried adding the following code on the DataBinding event for my DropDown:

ReferenceDataSource1.SelectParameters.Remove(ReferenceDataSource1.SelectParameters["component"]);
ReferenceDataSource1.SelectParameters.Add("component", "MB");

But I ironically got a StackOverflowException...