BIndingSource Update Issue

I have a textbox linked to a dataset using bindingsource. What's happening is that when i want to save the changes to the database it is not taken the changes.
I use something like this.
bb.bindingsource.endedit();
dttableadapter.update(datasetname.table);
If I look at the dataset in the IDE viewer I can see the record that has been changed properly. For some reason it not flagging as changes though.
I have even tried:
Datatable data = datasetname.table.getchanges();
int rec = data.rows.count
and nothing shows. It is just a null value. I am not sure if I am missing something for the bindingsource or not.
Very odd.

This is c# and 2005.

Any ideas would be great!
LVL 8
bman9111Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
topdog770Connect With a Mentor Commented:
Also, bman, where do you call EndEdit from and what is the bb object?  

I typically set up a function, like the Row_TextChanged function below that I call when the user changes the text in any bound controls.

Calling the EndEdit() function pushs the changes back to the dataset / datatable, etc behind the binding source
 void Row_TextChanged(object sender, EventArgs e)
        {
            this.bindingSource1.EndEdit( );
            Products.PACK_LABEL_PRODUCTSRow r = this.GetCurrentBindingSourceRow( );
 
            if (r != null)
            {
                if (r.RowState == DataRowState.Modified)
                {
                    SetSaveButtonEnabled( true );
                }
            }
        }

Open in new window

0
 
topdog770Commented:
How are you connecting your bindingsource to the datatable?

Are you calling AcceptChanges somewhere along the way?
0
 
bman9111Author Commented:
I am connected through the datatable component. No I have not used any acceptchanges command.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
topdog770Commented:
If you call getchanges from the databinding itself, are the changes visible.  I'm thinking that there may be a disconnect between your binding and the dataset table your checking for changes.
0
 
bman9111Author Commented:
No its not showing changes. The weird part is that if you place your cursor over it via the IDE you can see the row changes.

0
 
topdog770Commented:
Do you have a datagridview using the same binding source as the TextBox?  If so, make a change in the textbox THEN click in the datagridview and I am expecting that the dataset will have changes that get updated to the DB
0
 
topdog770Commented:
If you have an OK button or some similiar, you could also put the EndEdit there.
0
 
bman9111Author Commented:
ok. I redid all the binding and all seems ok. However even if a change is not done to any of the textboxs it still states there is a change to the dataset.
I am not sure why.

0
All Courses

From novice to tech pro — start learning today.