Home All Groups Group Topic Archive Search About
Author
10 May 2007 4:40 PM
Vernon Peppers
I am having trouble with the binding of a check box.  I have a form for
editing and adding reps.  I am using a bindingsource and a bindingnavigator. 
I have on the form an "Active" checkbox, which is bound to the IsActive field
in the bound data table.  It works fine for the reps that are already in the
table.  The problem occurs when I click on the AddNew button on the
bindingnavigator.  I have the field in the table to default to true, because
when I add a rep, he will be active.  The checkbox is checked when the AddNew
is clicked, but that data is never written back to my underlying data. 
Everything else is written, but the IsActive field is false, despite what is
in the check box.  How can I get the new rep to have the IsActive field set
to true?

Author
11 May 2007 12:39 AM
Flomo Togba Kwele
Vernon,

What type of the DataSource? Dataset or customer object: Have you checked the underlying data after
it is created to make sure Active is set true?

How do you know it's the binding and not the routine to write it back? Have you checked the
underlying data just before it is written back to the DB?

Flomo
--




Vernon Peppers wrote:

Show quote
> I am having trouble with the binding of a check box.  I have a form for
> editing and adding reps.  I am using a bindingsource and a bindingnavigator. 
> I have on the form an "Active" checkbox, which is bound to the IsActive field
> in the bound data table.  It works fine for the reps that are already in the
> table.  The problem occurs when I click on the AddNew button on the
> bindingnavigator.  I have the field in the table to default to true, because
> when I add a rep, he will be active.  The checkbox is checked when the AddNew
> is clicked, but that data is never written back to my underlying data. 
> Everything else is written, but the IsActive field is false, despite what is
> in the check box.  How can I get the new rep to have the IsActive field set
> to true?
Author
11 May 2007 1:46 PM
Vernon Peppers
The underlying database is an Access database.  I have checked and it is not
set True.

The only routine to write the data back is:

        Me.RepsBindingSource.EndEdit()
        Me.RepsTableAdapter.Update(dt)
        dt.AcceptChanges()

The rest of the data is written back, so I don't understand why the Active
field isn't.

Show quote
"Flomo Togba Kwele" wrote:

> Vernon,
>
> What type of the DataSource? Dataset or customer object: Have you checked the underlying data after
> it is created to make sure Active is set true?
>
> How do you know it's the binding and not the routine to write it back? Have you checked the
> underlying data just before it is written back to the DB?
>
> Flomo
> --
>
>
>
>
> Vernon Peppers wrote:
>
> > I am having trouble with the binding of a check box.  I have a form for
> > editing and adding reps.  I am using a bindingsource and a bindingnavigator. 
> > I have on the form an "Active" checkbox, which is bound to the IsActive field
> > in the bound data table.  It works fine for the reps that are already in the
> > table.  The problem occurs when I click on the AddNew button on the
> > bindingnavigator.  I have the field in the table to default to true, because
> > when I add a rep, he will be active.  The checkbox is checked when the AddNew
> > is clicked, but that data is never written back to my underlying data. 
> > Everything else is written, but the IsActive field is false, despite what is
> > in the check box.  How can I get the new rep to have the IsActive field set
> > to true?
>
Author
11 May 2007 4:52 PM
Flomo Togba Kwele
Vernon,

Place this line between the EndEdit and Update methods:

Dim row As dsReps.RepsRow = DirectCast(DirectCast(RepsBindingSource.Current, DataRowView).Row,
dsReps.RepsRow)

The variable row represents a row in the dataset. I'm not sure of the dataset name and table row
name, but substitute the proper variable names. Then in debug, set a breakpoint and look at the
value of Active. Is it what you expect?

You could also use QuickWatch in debug if your familiar with walking the data structure.
--



Vernon Peppers wrote:

Show quote
> The underlying database is an Access database.  I have checked and it is not
> set True.
>
> The only routine to write the data back is:
>
>         Me.RepsBindingSource.EndEdit()
>         Me.RepsTableAdapter.Update(dt)
>         dt.AcceptChanges()
>
> The rest of the data is written back, so I don't understand why the Active
> field isn't.
>
> "Flomo Togba Kwele" wrote:
>
> > Vernon,
> >
> > What type of the DataSource? Dataset or customer object: Have you checked the underlying data
> > after it is created to make sure Active is set true?
> >
> > How do you know it's the binding and not the routine to write it back? Have you checked the
> > underlying data just before it is written back to the DB?
> >
> > Flomo
> > --
> >
> >
> >
> >
> > Vernon Peppers wrote:
> >
> > > I am having trouble with the binding of a check box.  I have a form for
> > > editing and adding reps.  I am using a bindingsource and a bindingnavigator. 
> > > I have on the form an "Active" checkbox, which is bound to the IsActive field
> > > in the bound data table.  It works fine for the reps that are already in the
> > > table.  The problem occurs when I click on the AddNew button on the
> > > bindingnavigator.  I have the field in the table to default to true, because
> > > when I add a rep, he will be active.  The checkbox is checked when the AddNew
> > > is clicked, but that data is never written back to my underlying data. 
> > > Everything else is written, but the IsActive field is false, despite what is
> > > in the check box.  How can I get the new rep to have the IsActive field set
> > > to true?
> >
Author
11 May 2007 7:21 PM
Vernon Peppers
The only thing that this tells me is that all of the values in the table
currently are null.

Show quote
"Flomo Togba Kwele" wrote:

> Vernon,
>
> Place this line between the EndEdit and Update methods:
>
>  Dim row As dsReps.RepsRow = DirectCast(DirectCast(RepsBindingSource.Current, DataRowView).Row,
> dsReps.RepsRow)
>
> The variable row represents a row in the dataset. I'm not sure of the dataset name and table row
> name, but substitute the proper variable names. Then in debug, set a breakpoint and look at the
> value of Active. Is it what you expect?
>
> You could also use QuickWatch in debug if your familiar with walking the data structure.
> --
>
>
>
> Vernon Peppers wrote:
>
> > The underlying database is an Access database.  I have checked and it is not
> > set True.
> >
> > The only routine to write the data back is:
> >
> >         Me.RepsBindingSource.EndEdit()
> >         Me.RepsTableAdapter.Update(dt)
> >         dt.AcceptChanges()
> >
> > The rest of the data is written back, so I don't understand why the Active
> > field isn't.
> >
> > "Flomo Togba Kwele" wrote:
> >
> > > Vernon,
> > >
> > > What type of the DataSource? Dataset or customer object: Have you checked the underlying data
> > > after it is created to make sure Active is set true?
> > >
> > > How do you know it's the binding and not the routine to write it back? Have you checked the
> > > underlying data just before it is written back to the DB?
> > >
> > > Flomo
> > > --
> > >
> > >
> > >
> > >
> > > Vernon Peppers wrote:
> > >
> > > > I am having trouble with the binding of a check box.  I have a form for
> > > > editing and adding reps.  I am using a bindingsource and a bindingnavigator. 
> > > > I have on the form an "Active" checkbox, which is bound to the IsActive field
> > > > in the bound data table.  It works fine for the reps that are already in the
> > > > table.  The problem occurs when I click on the AddNew button on the
> > > > bindingnavigator.  I have the field in the table to default to true, because
> > > > when I add a rep, he will be active.  The checkbox is checked when the AddNew
> > > > is clicked, but that data is never written back to my underlying data. 
> > > > Everything else is written, but the IsActive field is false, despite what is
> > > > in the check box.  How can I get the new rep to have the IsActive field set
> > > > to true?
> > >
>
Author
11 May 2007 7:50 PM
Flomo Togba Kwele
Vernon,

Sorry about that. There is probably no current row then. Place that code in the CheckedChanged
event of the checkbox and look at the Active column, row.Active.


--

AddThis Social Bookmark Button