hey i am designing a Registration Page. In that i am having 3 comboboxes, one for country,one for state & last one for city. I am able to display all countries, states & cities entries from database. Here is my code.
SqlDataAdapter da = new SqlDataAdapter("select * from Country","Data Source=.;Initial Catalog=master;Integrated Security=True;");
da.Fill(ds);
int a =ds.Tables[0].Rows.Count;
for (int j = 0; j < a; j++)
{ comboBox1.Items.Add(ds.Tables[0].Rows[j][1]);
}
SqlDataAdapter da1 = new SqlDataAdapter("select * from City", "Data Source=.;Initial Catalog=master;Integrated Security=True;");
da1.Fill(ds1);
int i = ds1.Tables[0].Rows.Count;
for (int s = 0; s < i; s++)
{
comboBox2.Items.Add(ds1.Tables[0].Rows[s][1]);
}
}
[U][B]Now i want assistance on this, suppose a User select a Particular Country,say India then in the state combobox it displays States of India only & on selecting the State it displays Cities of that state only.
[/B][/U]
Thanks in Advance. :)
anish99virgo
0
Newbie Poster
Recommended Answers
Jump to Postwrite this code in comboBox1_click event.
SqlDataAdapter da1 = new SqlDataAdapter("select City_name from City where country_name='"+Combobox1.Text+"'", "Data Source=.;Initial Catalog=master;Integrated Security=True;"); da1.Fill(ds1); int i = ds1.Tables[0].Rows.Count; for (int s = 0; s < i; s++) { comboBox2.Items.Add(ds1.Tables[0].Rows[s][1]); }
All 4 Replies
abelLazm
183
Postaholic
Saikalyankumar
-2
Junior Poster in Training
Mitja Bonca
557
Nearly a Posting Maven
anish99virgo
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.