Setting the SelectedValue on a combobox

Hi there,

Sorry if this question is quite basic but am pretty new to C#. I have a form which has several combos - the Groups combo is connected to the detail table whose columns are all foreign keys.
The other combo boxes on the form represent a column on this table (which are databound to their respective masters)

I'm trying to set the value of the other combo boxes  based on the value selected in the group combo - on change, i can get the datarow which gives me the id value for each column.

Is there any way i can use the ID value to set the selected value on say the Staff combo?

dsSaphireOra.tblGroupsRow  dr = this.dsSaphireOra.tblGroups.FindByPK_GROUP(cboGroup.SelectedValue);
cboStaff.SelectedValue = dr.FK_SALES_STAFF  //Doesn't work!!

Open in new window

Who is Participating?
Ignis2Connect With a Mentor Author Commented:
It worked with a .ToString()!
Using the selected value will only work if you are using the combo box's valuemember property when binding the combo box to a dataset, datatable, etc.
Ignis2Author Commented:
That's what I think I've done?!
- pls see the attachment!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.