Click here to Skip to main content
14,877,073 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have three dropdown list for Contry, state n city....
If i select Country then respective state should bind , same for city...
Please need some advice...

Thanks in advance...
Posted

Try THis :

make auto post back=true property for country and state drpdown.

first bind country data from table.

double click on country dropdown:


 DataSet ds = new DataSet();
SqlDataAdapter myda = new SqlDataAdapter("Select state  FROM tablename where country='"+drop_country.SelectedItem.Value+"'", conn object);
drop_state.Fill(ds);
drop_state.DataSource = ds;
drop_state.DataValueField ="state";
drop_state.DataBind();


now double click on state drop down

        DataSet ds = new DataSet();
        SqlDataAdapter myda = new SqlDataAdapter("Select city  FROM tablename where state='"+drop_state.selectedItem.value+"'", conn object);
        drop_city.Fill(ds);
        drop_city.DataSource = ds;
        drop_city.DataValueField = "city";
        drop_city.DataBind();
<pre>

if any problem please post it.

Mitesh
   
v2
I think you have a tables like country_table, state_Table & city_table right...?

In your table you have a PK col is country_id, and you have a relation with state_table also, similarlly in city table also...

in your STATE DropDownList selected index changed event you write this query
SQL
SELECT STATE_Id,STATE_name,CITY_Id FROM STATE_TABLE WHERE COUNTRY_ID=DDLCOUNTRY.SELECTEDVALUE


IN your city dropdownlist selected index changed event you write the query simillar to state...


in your state detail's you must pass the country id, and in your city details you must pass the state_id...

Then fetch the information and assigned into DDL


Note: I'm given some sample information only not exact information
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900