How can I use a dataset as datasource for a combobox?

  • Thread starter Thread starter Johan Goris
  • Start date Start date
J

Johan Goris

I've tried to use a dataset as datasource for a combobox in the following
manner:



private void button1_Click(object sender, System.EventArgs e)

{

Classes.ProdOrders pr = new Classes.ProdOrders();

comboBox1.DataSource = pr.GiveList(1).Tables[0]; // a datasource is made,
sql is excecuted with a table with id and prodorder.

comboBox1.ValueMember = "id";

comboBox1.DisplayMember = "prodorder"; // can not bind!

}



But it cannot bind. What is wrong?
 
Do you get an exception? What does the combo display? Check field names and
that data is actually present in the table.
 
Back
Top