| Author: Sabu C Alex 28 Jul 2008 | Member Level: Gold | Rating: Points: 4 |
hi geetharam
What you have to do is
in the first dropdown list's selectedindexchaged event ie: protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { //Write code for binding data to second dropdownlist }
Here write the code for adding data to second dropdownlist.
|
| Author: muralidhar 28 Jul 2008 | Member Level: Gold | Rating: Points: 5 |
hai,
i think you are getting the citites in the selected country.
you are doing mistake when populating then dropdownlist.
lets take two dropdownlists ddlCountry and ddlCities
in ddlCountry selectedindexchanged event get all the cities for that country and bind the cities to ddlCities.
loop in dataset or datareader and place the below lines in that loop ddlCities.Items.Clear(); ddlCities.Items.Add(<dataset item or datareader item>);
regards, Muralidhar.
|
| Author: Mexi Renjith Mamman 28 Jul 2008 | Member Level: Gold | Rating: Points: 4 |
Is your problem is not showing cities related to selected country?
If it is you have to do like this:
First fill the dropdown of country and in the selected Index Changed event of that dropdown , take the selectedItem.Value of the Country and fill the dropdown for Cities with that selected value of country.
The dropdown of cities will be filled based on the selected Country.
|
| Author: G.Hemadribabu 28 Jul 2008 | Member Level: Gold | Rating: Points: 6 |
your requirement is on selection of country dd , that corresponding sitys shoudl be displayed in city dd . so
write the query in country dropdown box like this, (Give autopostback = true) select country coulmn, city column from table name where countrycolumn name = dd1.selectedvalue
and fill the results in city dropdown box,
This will surely work try it,
IF you need exact code, then tell me the columns name,table name and dropdown box's name, i will modify and send you teh code back
hopw thiswill work , takecare
|
| Author: Raghuramakarthikeyan 28 Jul 2008 | Member Level: Gold | Rating: Points: 6 |
Solution: In the Database you store as State and city like this: Table Name StateTable: State City Tamilnadu chennai Tamilnadu Trichy Karnataka Bangalore Karnataka Mysore
Like this and then write this query Select State From StateTable with this Fill the Drop Down and also make THe first dropdown Autopostback as true.. after selecting the first dropdown write the code in selectedindexchanged of first drop down, Select City from StateTable Where State='Tamilnadu' you will get the cities of tamil nadu
|