I’ve got a problem:
SqlDataAdapter da = new SqlDataAdapter("SELECT dbo.User.name FROM dbo.User", con);
DataTable dt = new DataTable();
comboBox1.DataSource = dt;
da.Fill(dt);
It returned System.Data.DataRowView in every row.
I tried:
comboBox1.ValueMember = "idUser";
comboBox1.DisplayMember = "dbo.User.name"
and I get error:
Cannot bind to the new display member. Parameter name:
newDisplayMember
I want to get idUser and name.
Thanks
You need to return the ID in your SELECT statement and assign the DataTable as the DataSource after you have filled the DataTable:
You can then set up the ComboBox as such:
UPDATE
If you want to access the selected text or value of the item selected in the ComboBox, then you will need to do something like: