none
Restrict display of certain names in DropDownList RRS feed

  • Question

  • Hi all. I am using Microsoft Visual Web Developer C# and am working with a database.

    I am using 2 tables: CONTINENT table with fields: CONTINENT_CODE and CONTINENT_NAME

    The other table is COUNTRIES with fields: COUNTRY_CODE and COUNTRY_NAME

    The 1 dropdownlist is bound to the CONTINENT table and displays the CONTINENT_NAME (with its value CONTINENT_CODE)

    The 2nd dropdownlist is bound to the COUNTRY TABLE and displays COUNTRY_NAME (with its value COUNTRY_CODE).

    Now my question is what can you do in order for a user to be only able to select Europe (from dropdownlist 1) then England and Spain appears (in drop down list 2) and not China. Thanks

    • Moved by Jason Dot Wang Thursday, May 16, 2013 5:37 AM This thread is about ASP.NET
    Monday, May 13, 2013 5:50 PM

All replies

  • There needs to be a relationship in your database that maps a country to a continent code.  You can then modify your query to get countries by requiring that you also specify the continent code.  Your query will then include a where clause that includes only countries with a continent code that matches. 

    In ASP.NET you are likely using a data source to control the lists.  Once you've added the relationship in you can refresh the data source.  This will allow you to specify a parameter to the country query that pulls its data from the continent lookup.  Refer to this article for an example of how you might solve it.

    Please post ASP.NET questions in the ASP.NET forums (http://forums.asp.net).

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Monday, May 13, 2013 7:05 PM