Posted By: brownsoft | Jun 5th, 2006 @ 2:46 AM
page 1 of 1
Comments: 2 | Views: 3231
Visual C# Express with SQL 2005 Express

I am creating a data aware application but I have ran into what feels like a 'hack' to me.

I have a form with a ComboBox which is databound to a database. The selectedValue field is mapped to a integer field in the db. So inside the SelectedIndexChanged Event when I do the following I get a null reference exception when the app closes:
  int idvalue = cmbbox.selectedValue


I notice if I add the following I no longer get an exception:
    if (cmbbox.selectedValue != null)
          idValue = cmbbox.selectedValue

Does this feel like a hack or is just me???  Why does selectedIndexChanged event get fired when the app closes??


leeappdalecom
leeappdalecom
.nettter
Probably becuase when the control gets destroyed all the items in the combo box get cleared therefore the selected index will change to null becuase the previously selected item has now dissapeard.
littleguru
littleguru
allein, allein,... allein, allein!
This is weird. I have done a lot databinding, but I never got this thing. Are you sure you are not calling or doing something that causes that behaviour?
page 1 of 1
Comments: 2 | Views: 3231