473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Check Box Binding

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?
May 10 '07 #1
6 4738
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?
May 11 '07 #2
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?
May 11 '07 #3
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?
May 11 '07 #4
The only thing that this tells me is that all of the values in the table
currently are null.

"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?
>
May 11 '07 #5
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.
--

May 11 '07 #6
row.Active didn't exist, and everything I tried to look at still was null.
However, I figured out a workaround to take care of my problem. My code is:

Me.RepsBindingSource.MoveFirst()
For i As Integer = 0 To Me.RepsBindingSource.Count - 1
Dim drv As DataRowView = Me.RepsBindingSource.Current
Dim row As DataRow = drv.Row
If row.RowState = DataRowState.Added Then
row.Item("IsActive") = True
End If
Me.RepsBindingSource.MoveNext()
Next
Me.RepsBindingSource.EndEdit()
Me.RepsTableAdapter.Update(dt)

If I step through this code, the value of row.Item("IsActive") is DBNull
before the statement assigning its value. Yet this box is bound to the
database. I still don't understand why it won't work. I think that we might
have a bug, but what I have done works.

"Flomo Togba Kwele" wrote:
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.
--

May 15 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: deko | last post by:
I'm trying to create an MSI in VS.NET that will check for installed Office System components - so my MDE will only install if requirements are met. I'm thinking about using VBScript to inspect...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
1
by: Hardik Shah | last post by:
Hi, I have created data form from wizard for a table which has a field with bit type . The table has one field with not null value . However, I fill the field , however, it gives following...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
9
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
1
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
how can i add a check box to binding navigator control? thanks
4
by: haresh.amis | last post by:
hello to all, I m using .net 2.0 and i face a problem that is as under Well I have a checkboxlist which i bound in .cs page now I want to count that how many checkboxes ate checked ( In...
6
by: parez | last post by:
Is there anyway i can find out if a control is an input control (textbox,radiobutton,checkbox,dropdown etc) and not a panel,group box etc. I am trying to implement "You have unsaved data on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.