Click here to Skip to main content
15,888,081 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have 2 combo box, comboBox1 item was taken from databinding(table1"Root" contains ID and Root, table2"Parent" contains ID, Parent, RootID). The item list for comboBox2 are depends on selected value from comboBox1.. the problem is, i can't filter the comboBox2.Displaymember.. please help, here is my codes:

C#
private void comboBox2_DropDown(object sender, EventArgs e)
        {
            cn.Open();
            //comboBox2.DataSource = parentBindingSource;
            SqlCommand cb2 = new SqlCommand("SELECT * FROM PARENT WHERE RootID = " + comboBox1.SelectedValue.ToString(), cn);
            SqlDataAdapter dat = new SqlDataAdapter(cb2);
            DataSet ds = new DataSet();
            dat.Fill(ds, "Parent");
            comboBox2.DataSource = ds;
            cn.Close();
        }


Please help..
Posted
Comments
Sadique KT 3-Jul-13 4:44am    
Whatz d result u r getting? try after writing the above code in selected index changed/editvalue changed etc, of combobox1..

1 solution

comboBox2.DataSource = ds;
comboBox2.DisplayMember = "ColumnName1";
comboBox2.ValueMember = "ColumnName2";
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900