Databound Checkbox problems with Bindingcontext.addnew()

  • Thread starter Thread starter Will Dobbins
  • Start date Start date
W

Will Dobbins

I've got a dataset and a windows form I've bound my controls too. I
have two fields that are True/False in the SQL server and wanted to
use checkboxes for those... Everything looks fine, you can navigate
through existing records, etc, right up until you try to add a new
record:

this.BindingContext[this.dsCharacters, "tblCharacters"].AddNew();

Once you do that, nothing appears to happen.

I've traced this down to the checkbox controls, if I unbind them I can
add new records to my dataset and write them back out to the DB
without any problems...

Am I doing something wrong, is there additional code that I'm missing?

Thanks in advance!

Will Dobbins
Online Gaming - Comments and News
http://www.ogcan.com
 
Will said:
this.BindingContext[this.dsCharacters, "tblCharacters"].AddNew();

Why aren't you adding new records directly to
this.dsCharacters.tblCharacters? The currency manager should handle the
additional record and move the bound controls there.

--Mike
 
Hrm, I didn't even know that was an option... I did find the resolution
and I'd wager that the problem would exist either way I added the
records.

The short version is my dataset didn't have default values associated to
the checkbox fields, so the binding didn't know how to handle that...

I'll try just adding the row to the dataset though, probably lots of
reasons I'd want to do that right?

--Will (I really need to choose how I post to usenet and stick with one
way!)
 
Back
Top