I had created something similar in nature when working on an ADO.NET
project back in February with VC# frontend - here's the code,I hope it
helps...
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.Text == "Allahabad")
{
comboBox1.Items.Clear();
comboBox1.Items.Add("Alopibagh");
comboBox1.Items.Add("George Town");
comboBox1.Items.Add("Civil Lines");
comboBox1.Items.Add("Katra");
comboBox1.Items.Add("Chowk");
comboBox1.Items.Add("Teliyargunj");
comboBox1.Items.Add("Jhusi");
comboBox1.Items.Add("Tagoretown");
comboBox1.Items.Add("Phulpur");
comboBox1.Items.Add("Allahpur");
comboBox1.Items.Add("Rambagh");
comboBox1.Items.Add("High Court");
}
else if (listBox1.Text == "Dehra Dun")
{
comboBox1.Items.Clear();
comboBox1.Items.Add("Jakhan");
comboBox1.Items.Add("Astley Hall");
comboBox1.Items.Add("Paltan Bazaar");
comboBox1.Items.Add("Doon Vihar");
comboBox1.Items.Add("Mussoorie");
comboBox1.Items.Add("Rajaji National Park");
comboBox1.Items.Add("Veerbhadra");
comboBox1.Items.Add("ITBP");
}
else if (listBox1.Text == "Kolkata")
{
comboBox1.Items.Clear();
comboBox1.Items.Add("Park Street");
comboBox1.Items.Add("Nabaliyapada");
comboBox1.Items.Add("Victoria Memorial");
comboBox1.Items.Add("Alipur");
comboBox1.Items.Add("North Parganas");
comboBox1.Items.Add("Howrah");
comboBox1.Items.Add("Sodepur");
comboBox1.Items.Add("Shyambazar");
}
else if (listBox1.Text == "Lucknow")
{
comboBox1.Items.Clear();
comboBox1.Items.Add("Gomti Nagar");
comboBox1.Items.Add("Hazratgunj");
comboBox1.Items.Add("Sarvodaya Nagar");
comboBox1.Items.Add("Orai");
comboBox1.Items.Add("Parivartan Chowk");
comboBox1.Items.Add("Dilkusha");
comboBox1.Items.Add("Hazratganj");
comboBox1.Items.Add("Thakurganj");
comboBox1.Items.Add("Alambagh");
comboBox1.Items.Add("Lal Bagh");
comboBox1.Items.Add("Rajajipuram");
comboBox1.Items.Add("Golaganj");
comboBox1.Items.Add("Wazirganj");
comboBox1.Items.Add("Rajendra Nagar");
}
else if (listBox1.Text == "Mumbai")
{
comboBox1.Items.Clear();
comboBox1.Items.Add("Dadar");
comboBox1.Items.Add("Churchgate");
comboBox1.Items.Add("Ghatkopar");
comboBox1.Items.Add("Andheri");
comboBox1.Items.Add("Bandra");
comboBox1.Items.Add("Juhu");
comboBox1.Items.Add("Chor Bazaar");
comboBox1.Items.Add("Nariman Point");
comboBox1.Items.Add("Sunder Nagar");
comboBox1.Items.Add("Nana Chowk");
comboBox1.Items.Add("Bhindi Bazaar");
}
else if (listBox1.Text == "New Delhi")
{
comboBox1.Items.Clear();
comboBox1.Items.Add("Connaught Place");
comboBox1.Items.Add("Jamia Nagar");
comboBox1.Items.Add("South Extension");
comboBox1.Items.Add("Nehru Park");
comboBox1.Items.Add("Mayur Vihar");
comboBox1.Items.Add("Jamia Nagar");
comboBox1.Items.Add("Ghaziabad");
comboBox1.Items.Add("Noida");
comboBox1.Items.Add("Karol Bagh");
}
}
you can then insert validations to make it mandatory for a person to
select a country - then state and finally city. there are 192
countries god knows how many provinces and states,and countless
cities.
On Sep 2, 9:02 pm, Cerebrus <[email protected]> wrote:
> This is a pretty common requirement. Implementations may vary. Here's
> a generic scenario:
>
> At first, only the countries should filled in the first ComboBox. Upon
> selection, a postback request should occur to the server which passes
> the selected country ID and retrieves the state ID's and names and
> fills the second ComboBox. Then when a State is selected, you can
> repeat the process passing the selected State ID and retrieve the
> Cities list to populate the third ComboBox. If you do not want a
> visible postback upon each index change, you could make the UI much
> more user friendly by sending an out-of-band request (read "AJAX") to
> retrieve the data in each case.
>
> The question I would ask you is what will you do for those countries
> which have no states? IMO, a good idea would be to determine at the
> client side itself if a particular Country has States, and if not,
> directly request for Cities.
>
> On Sep 2, 8:01 pm, aditya chavan <[email protected]> wrote:
>
> > Hello
> > I want some help.
> > i have to make an customer detail information its in C#. and in which i have
> > to make 3 combo boxes which contains all countries, states & cities
> > respectively.
> > now what i want is that when i select any country accordingly i should get
> > all its states and selecting particular state i should get cites.
> > now the problem is that everyone knows that there are many countries ,
> > states and their thousands of cities,
> > so can anyone provide help regarding this how can i do it in much faster
> > way.or anyone already have developed this thing can mail me that will me in
> > much better way.
> > or can give some idea about this or give any site from where i can get help
> > this..??
>
> > i hope everyone have got what i want..!!
>
> > waiting for your reply..!!!
>
> > Thank you..!!
>
> > Aditya Chavan