2 sql database driven drop-down lists to link up

Development plaform: C# ASP.net 2.x, SQL 2005, MS Visual Studio Pro using Web Developer, IIS 6

Hi there,

I am trying to get these 2 sql database driven drop-down lists to link up.

i.e. depending on what the first drop-down list option is select will determine what the second drop-down list will display.  Essentially, fire-up another sql search for related records etc.

Below is the shell of the program -- these 2 sql-based drop-down menus are working fine independately -- just need to get them to link up.

Could someone please add to this scripting the additional coding I need to consider in order to get it working?

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
            DataTextField="LeadSourceProviderName" DataValueField="LeadSourceProvider_ID">
        </asp:DropDownList>
        &nbsp; &nbsp;
        <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2"
            DataTextField="LeadSourceProviderProductName" DataValueField="LeadSourceProviderProducts_ID">
        </asp:DropDownList><br />
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FORTUNEConnectionString %>"
            SelectCommand="SELECT [LeadSourceProvider_ID], [LeadSourceProviderName] FROM [LeadSourceProviders] ORDER BY [LeadSourceProviderName]">
        </asp:SqlDataSource>
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:FORTUNEConnectionString %>"
            SelectCommand="SELECT [LeadSourceProviderProducts_ID], [LeadSourceProviderProductName], [LeadSourceProvider_ID] FROM [LeadSourceProviderProducts] ORDER BY [LeadSourceProviderProductName]">
        </asp:SqlDataSource>


Thank you in advance for your time and efforts with this enquiry.
amillyardAsked:
Who is Participating?
 
SammyCommented:
The Second SqlDataSource MUST have a relationship between itself and the First Dropdownlist

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:FORTUNEConnectionString %>"
            SelectCommand="SELECT [LeadSourceProviderProducts_ID], [LeadSourceProviderProductName], [LeadSourceProvider_ID] FROM [LeadSourceProviderProducts] WHERE ([LeadSourceProvider_ID] = @LeadProviderId) ORDER BY [LeadSourceProviderProductName]">
<SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="LeadProviderId" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>      
 </asp:SqlDataSource>
 
0
 
SammyCommented:
AutoPostaback should be set to true in the first Dropdownlist
0
 
amillyardAuthor Commented:
ok, done that -- but this is not making the 2nd dro-down box react any differently, only that the screen page refreshes.
0
 
amillyardAuthor Commented:
100 % spot on -- apprieate your time and efforts with enquiry.

thank you.
0
 
SammyCommented:
You welcome :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.