Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 21-Feb-13 1:39am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
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
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.141022.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100