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 326701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:20:02+00:00 2026-05-12T09:20:02+00:00

I have 2 linked database tables (Similar to Country -> State) – how can

  • 0

I have 2 linked database tables (Similar to Country -> State) – how can I dynamically populate 2 drop down lists with these tables such that:

If I pick a Country, only the states for that country show up in the second drop down list?

Update:
There seems to be a solution on this page -> Populate DropdownList based upon other DropDownList VB -> the one that uses the SQL Data connection on the aspx page itself, databinding the dropdowns – how do I do this with LINQ? I think I can figure it out from here.

  • 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-05-12T09:20:02+00:00Added an answer on May 12, 2026 at 9:20 am

    You have your state control hidden, and autopostback = true on your Country dropdownlist.

    On the SelectedIndexChanged, you pull that value and query your database with that, and then set your state drop down list to visible.

    In the ASPX page:

    <asp:DropDownList ID="CountryDD" runat="server" AutoPostBack="true" OnSelectedIndexChanged="CountryDD_IndexChanged" />
    
    <asp:DropDownList ID="StateDD" runat="server" Visible="false"/>
    

    In the Code Behind:

    Protected Sub CountryDD_IndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        StateDD.Items.Clear()
        Using conn As SqlConnection = New SqlConnection("Connection String")
            conn.Open()
            Using cmd As SqlCommand = New SqlCommand("get_states_by_country", conn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@country_id", CountryDD.SelectedValue)
                Using dr As SqlDataReader = cmd.ExecuteReader()
                    StateDD.Items.Add(New ListItem(dr("state_name").ToString(), dr("state_id")))
                End Using
            End Using
        End Using
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three database tables: users emails invitations Emails are linked to users by
In a MySQL database I have two tables linked in a join. One table
I have 2 similar tables on different databases. I already linked the remote DB
In my database, I have 3 tables that have 2 similar columns, Year and
I am using Access 2007 and have some linked tables to a mySQL database.
I have a mysql database with two tables, bookings and users. They are linked
I have a linked Firebird database on my SQL Server 2008 via ODBC. I
I have a completely empty RavenHQ database that's linked to my Appharbor application. The
I have a database table where all the records are linked among each other
I have 4 tables, linked in a circular reference - I remember from college

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.