Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a drop down list that bound to a SqlDataSource.

I have another drop down list that's bound to a different SqlDataSource.

The second SqlDataSource has the first drop down as a Control Parameter.

I'm trying to do this...

<asp:SqlDataSource ID="sqlDataSource2" runat="server"
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT * FROM Test WHERE Param = @param;"
    CancelSelectOnNullParameter="true">
    <SelectParameters>
        <asp:ControlParameter ControlID="dropDown1" Name="param"
            PropertyName="SelectedValue"
            ConvertEmptyStringToNull="true" />
    </SelectParameters>
</asp:SqlDataSource>

dropDown1.SelectedValue = "someValue"
dropDown2.DataBind()

but I don't get any results. However, if I set the second SqlDataSource's Control Parameter to a text box, it works. For example, this works:

<asp:ControlParameter ControlID="txt" Name="param"
    PropertyName="Text"
    ConvertEmptyStringToNull="true" />

txt.Text = "someValue"
dropDown2.DataBind()

Any ideas why this is?

share|improve this question
    
are you sure you have your datatextfield and datavaluefield arranged properly? Plus do you have autopostback set to true for both controls? – briskovich Mar 22 '13 at 23:31
up vote 1 down vote accepted

I ended up figuring this one out. The problem was that the drop down was attempting to bind twice, much like the problem in this question.

I used the suggestion made by Joel Etherton, and now it works perfectly. Although I used a hidden control rather than a label.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.