P
Paul
Is there a bug when trying to bind a data table to ListBox?
After reading just about every post and MSDN article on
data binding to a ListBox and ComboBox (which is suppose
to be the same from everythng I've read) I could not get
the ListBox to accept binding. As soon as I assign a
column of the table to the DisplayMember, the ListBox
would barf with and error message saying you can't change
the collection after assigning the data source to the
ListBox.
On the first try with the comboBox it worked. The ListBox
worked fine with an ArrayList, but of course that doesn't
change dynamically when the ArrayList changes.
Code sample follows:
SqlConnection conn = new +
SqlConnection "server=bullet.francomm.com; uid=paul; +
pwd=oct99sun; database=jewel");
da2= new SqlDataAdapter(classTbl, conn);
da2.Fill(ds, "class");
comboBox1.DataSource= ds;
comboBox1.ValueMember="class.id";
comboBox1.DisplayMember="class.class";
If listBox is used, this code doesn't work (and every
other alternative coding). Anybody have any ideas? or is
this just another bug?
Paul.
After reading just about every post and MSDN article on
data binding to a ListBox and ComboBox (which is suppose
to be the same from everythng I've read) I could not get
the ListBox to accept binding. As soon as I assign a
column of the table to the DisplayMember, the ListBox
would barf with and error message saying you can't change
the collection after assigning the data source to the
ListBox.
On the first try with the comboBox it worked. The ListBox
worked fine with an ArrayList, but of course that doesn't
change dynamically when the ArrayList changes.
Code sample follows:
SqlConnection conn = new +
SqlConnection "server=bullet.francomm.com; uid=paul; +
pwd=oct99sun; database=jewel");
da2= new SqlDataAdapter(classTbl, conn);
da2.Fill(ds, "class");
comboBox1.DataSource= ds;
comboBox1.ValueMember="class.id";
comboBox1.DisplayMember="class.class";
If listBox is used, this code doesn't work (and every
other alternative coding). Anybody have any ideas? or is
this just another bug?
Paul.