Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox SelectedValue binding issue

Status
Not open for further replies.

alanmusician

Programmer
Jun 30, 2005
17
US
I'm having an issue with the combobox when binding to SelectedValue. ValueMember and DisplayMember are bound to a collection of custom objects as "Id" and "Species". SelectedValue is bound to another custom object as "SpeciesID". The collection is loaded from a database.

This all works quite well except when adding a new item to the collection. Here is what happens:

A new item is added to the collection by the user. The new item is created with an "Id" of 0. When the item is selected, the SelectedValue changes to 0, and propagates to "SpeciesID" as expected. Now, when the item is written back to the database, the "Id" gets set to 5 or whatever, and so SelectedValue turns to "5" as well. It does not, however, propagate to "SpeciesID" even though they are bound, and work correctly under all other circumstances.

Another oddity: I can set a watch on SelectedValue and watch it change from 0 to 5 on the line of code that sets "Id", but the OnSelectedValueChange event never fires.

Does anyone know why I am getting such odd behavior?

Thanks,
--Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top