Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9282115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:17:39+00:00 2026-06-18T18:17:39+00:00

I use 2 dropdownlist which is parent-child controls that show list of data from

  • 0

I use 2 dropdownlist which is parent-child controls that show list of data from SQL Server. I wanted to make it happen when I selected second dropdownlist, the DetailsView will display result from what I selected. If I select database name is Database3, I want DetailsView to show all result from database3. I tried do some coding and the detailsview doesn’t show anything. Please help! Here my dropdownlist codes,

<asp:DropDownList ID="DropDownServerName" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="ServerName" DataValueField="ServerName">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [ServerName] FROM [tblServer]"></asp:SqlDataSource>
    <br />
    <br />
    <br />
    <asp:Label ID="Label10" runat="server" Text="Select Database:"></asp:Label>
    <br />
    <asp:DropDownList ID="DropDownDatabase" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="DatabaseName" DataValueField="DatabaseName" OnSelectedIndexChanged="DropDownDatabase_SelectedIndexChanged">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [DatabaseName] FROM [tblDatabase] WHERE [ServerName] = @ServerName">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownServerName" Name="ServerName" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>

Then in DetailsView, I don’t want to put too much codes for you have to go look all trough but the DetailsView had Update, Delete, and Insert Function. They come with DataSourceID is SQLDataSource1 which it BoundField from table Database. In SQLDataSource1, on SelectCommand, I type,

SelectCommand="SELECT * FROM [tblDatabase] WHERE [DatabaseName] = @DatabaseName"

Then I add SelectParameter in SQLDataSource1 from selected dropdownlist for this,

<SelectParameters>
            <asp:ControlParameter ControlID="DropDownDatabase" Name="DatabaseName" PropertyName="SelectedValue" />
        </SelectParameters
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:17:41+00:00Added an answer on June 18, 2026 at 6:17 pm

    Here is some code for a page I built using the same requirements. I had two drop down lists, one for names of customers, and the other for the products they bought. The detailsview would display the full details for any product selected in the second drop drop list.

    I think this is what you were going for. Keep in mind that when you set up the datasources for the 2nd drop down list and the detailsview you have to make sure that you use the wizard to create a where clause so that both grab the primary keys from the drop down list controls.

    For example the sqldatasource1 (see bottom of code) has the ControlID set as “ddlProducts” with the PropertyName as “SelectedValue”. The detailsview using the sqlDataSource1 runs the select statement using the selected value of the Products dropdownlist. Hopefully this helps.

    <table class="style4">
            <tr>
                <td>
                    Customer:</td>
                <td>
            <asp:DropDownList ID="ddlCustomers" runat="server" 
                DataSourceID="ObjectDataSource1" AutoPostBack="True" DataTextField="Name" 
                DataValueField="CustomerID" AppendDataBoundItems="True" 
                onselectedindexchanged="ddlCustomers_SelectedIndexChanged">
                 <asp:ListItem Text="--Select a customer--" Value="0"></asp:ListItem>
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="CustomerDB" SelectMethod="GetCustomerList">
            </asp:ObjectDataSource>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="ddlCustomers" ErrorMessage="Please select a Customer" 
                        InitialValue="0"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Product</td>
                <td>
            <asp:DropDownList ID="ddlProducts" runat="server" AutoPostBack="True" 
                DataSourceID="ObjectDataSource2" DataTextField="Name" 
                DataValueField="ProductCode" AppendDataBoundItems="True" 
                        onselectedindexchanged="ddlProducts_SelectedIndexChanged">
                <asp:ListItem Text="--Select a product--" Value="0"></asp:ListItem>
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                SelectMethod="GetCustomerProducts" TypeName="ProductDB" 
                OldValuesParameterFormatString="original_{0}">
                <SelectParameters>
                    <asp:ControlParameter ControlID="ddlCustomers" Name="CustomerID" 
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ControlToValidate="ddlProducts" ErrorMessage="Please select a product" 
                        InitialValue="0"></asp:RequiredFieldValidator>
                </td>
            </tr>
    
        </table>
    
    
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataKeyNames="ProductCode" DataSourceID="SqlDataSource1" Height="50px" 
            Width="125px">
            <Fields>
                <asp:BoundField DataField="ProductCode" HeaderText="ProductCode" 
                    ReadOnly="True" SortExpression="ProductCode" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Version" HeaderText="Version" 
                    SortExpression="Version" />
                <asp:BoundField DataField="ReleaseDate" HeaderText="ReleaseDate" 
                    SortExpression="ReleaseDate" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:TechSupport_DataConnectionString %>" 
            SelectCommand="SELECT [ProductCode], [Name], [Version], [ReleaseDate] FROM [Products] WHERE ([ProductCode] = @ProductCode)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlProducts" Name="ProductCode" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna use DropDownList to choose an Item pf a list which comes from
I read that one cannot use ASP.NET MVC with Server Control which have ViewState
I have an ASP.NET webform on which I use a DropDownList control to allow
I have a simple jquery function which I use to show/hide some divs. The
I have several Telerik's DropDownList controls which are rendered inside jQuery dialog It is
I have DropDownList, which has some options to choose from. Now after when user
I'm using a DropDownList to pull up data from FormViews and properly calculate it.
I have the following method which I use to fill a DropDownList-Control. protected void
I have a DropDownList control that is populated with TimeZones from calling: ReadOnlyCollection<TimeZoneInfo> tzCollection;
From the examples below showing the loading of a DropDownList in ASP.NET which method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.