I'm using C# in Visual Studio 2010. I have 2 comboboxes that pull data from the database. The code looks something like this:
cbo1.DisplayMember = "Name";
cbo1.ValueMember = "HROfficeLocationID";
cbo1.DataSource = offices;
cbo2.DisplayMember = "Name";
cbo2.ValueMember = "HROfficeLocationID";
cbo2.DataSource = offices;
I kept getting this exception: 'Cannot bind to the new value member. Parameter name: newDisplayMember'. I searched around and then reorganized the lines of code so that cbo.DataSource came before .DisplayMember and .ValueMember .It ended up looking something like this:
cbo1.DataSource = offices;
cbo1.DisplayMember = "Name";
cbo1.ValueMember = "HROfficeLocationID";
cbo2.DataSource = offices;
cbo2.DisplayMember = "Name";
cbo2.ValueMember = "HROfficeLocationID";
The exception went away. Just thought I'd share.