Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I need to populate multiple columns from sql DB to MultipleColumnCombobox.

I have refered followed following link and and I am ale to populate the hard coded data to multicolumn combo box.

Multi Column ComboBox[^]

Now I would like to read the data from sql DB to combobox. I am able to do it but when i click on combo box the data from database appears for fraction of second and then disappears.

Not sure what is causing the problem.

Please help.

I have attached my code for reference

C#
private void button1_Click(object sender, EventArgs e)
       {

           CreateDataTable();
           multiColumnComboBox1.Table = dtable;
           multiColumnComboBox1.DisplayMember = "DoctorName";
           multiColumnComboBox1.ColumnsToDisplay = new string[] { "DoctorID", "DoctorName" };
           button1.Enabled = false;

       }

       private void CreateDataTable()
       {
           dtable = new DataTable("Rock");
           //set columns names
           dtable.Columns.Add("Doctor ID", typeof(System.String));
           dtable.Columns.Add("Doctor Name", typeof(System.String));


           con.Open();
           SqlDataAdapter da = new SqlDataAdapter("SELECT DoctorID, DoctorName FROM DoctorTabl", con);

               dataset = new DataSet();
               da.Fill(dataset, "DoctorTabl");
               dtable = dataset.Tables["DoctorTabl"];

       }
Posted
Updated 15-Dec-13 0:09am
v2

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