Object reference not set!

  • Thread starter Thread starter Gilgamesh
  • Start date Start date
G

Gilgamesh

Hi,
Assigning the DataSource of a Combobox to a dataview, on a win form, throws
the exception "Object reference not set to an instance of an object". The
ComboBox has already been created and is a valid object. The Dataview is
also valid and has data in it. Any idea why this exception is thrown?

Thanks,
Gilgamesh
 
Could you reply with a short but complete example in which the problem is
reproduced? Instead of binding to a Dataview filled from a database, you
could try filling the Dataview manually somehow. If you can only reproduce
the problem with a database, I don't know that we could help you.

Chris
 
Here is the code:

Branch br = new Branch();
dv = br.GetBranchesAll().DefaultView;
cmbBranchNum.DisplayMember = "BRANCH_NO"; //No Exception is thrown
here
cmbBranchNum.ValueMember = "BRANCH_NO"; //No Exception is thrown here
cmbBranchNum.DataSource = dv; //Here is where
the exception is thrown

BTW, I've got a couple of other combo boxes on this form, and they all work
just fine.

Thanks,
G.
 
Back
Top