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

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?
 
S

Sijin Joseph

Do you get an exception? What does the combo display? Check field names and
that data is actually present in the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top