Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL combobox
I would like to make like 4 comboboxes where each list within the combobox derives from the previous one. I thought this would be as easy as setting each box to a variable and then using that variable in the query for the combobox after it. I have attempted to use a variable in the query editor in the fillby, and also attempted to use code like this:
            using (SqlConnection cs = new SqlConnection(
@"Data Source=100-olkj-900-ptalog=Report;Persist Security Info=True;User ID=reports;Password=password
            {
                cs.Open();
 
 
                using DataAdapter da = new SqlDataAdapter(query
                {
                    // 3
                    
                    DataTable t = new DataTable();
                    da.Fill(t);
 
                    // 4
                    // Render data onto the screen
                    comboBox1.DataSource = t; // <-- From your designer
                    comboBox1.DisplayMember = "station.stationipaddress";
                    comboBox1.ValueMember = "station.stationipaddress";
 
                }
 
I am not really sure, what to try...
Any ideas anyone >?
Posted 16-Jan-13 18:05pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

Solution 2

Hello Prevatt, This link will help u surely. For this purpose we can use cascading drop downs, these are also so-called dependancy drop downs while loading the consequent drop down it wont effect the entire page i.e, updates only the partial page or specific drop down. Try this code
http://www.aspdotnet-suresh.com/2012/11/country-state-city-cascading.html[^]
 
Happy Coding....
  Permalink  
v3

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 16 Jan 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