I don't fully understand control binding in c# programs and wonder if
someone could clarify things for me.

I have two related tables ...

Parent: USERS (names)
Child: USER_CONTACT (telephone numbers, etc)

To the child table I've bound several textboxes as follows ...

myTextbox.DataBindings.Add("Text", ds.USERS, "USER_USERCONTACT.FIELD_NAME");

All of this works great. My problem is updating the datasource with changes
made to the textbox values. Specifically, the routines below successfully
pass updates to the datasource just once. After that, in spite of making
more edits, the routines don't pass changes back to the datasource.

Here are the main events in the code ...

BindingContext[ds.USERS, "USER_USERCONTACT.FIELD_NAME"].EndCurrentEdit();

daUSERS.Update(ds.USERS);
daUSERS.Fill(ds.USERS);

daUSERContact.Update(ds.USER_CONTACT);
daUSERContact.Fill(ds.USER_CONTACT);

Since my controls remain bound through the update and re­fill I assume that
maybe "EndCurrentEdit()" has ended my editing session and, for additional
editing, I need to somehow "begin edit." It's at this point that I realize
the greater problem is my not having any idea what I'm doing!

Thanks in advance for advice.

Re: Textbox DataBinding by W

W
Sun Aug 28 20:11:00 CDT 2005

After you make the additional edits, are you calling EndCurrentEdit again?
that's the most likely problem here. To be sure of the rowstate, use a
Debug.Assert(ds.USERS.HasChanges(), "There are no changes present"); before
each update. - If the assertion fails, then calling update isn't going to
matter but if it's true, there could be some other problems. Is this code
behind a Save button so the same stuff happens each time?
"Joe Reggae" <JoeReggae@JoeReggae.org> wrote in message
news:11h44lhqi5ock77@corp.supernews.com...
>I don't fully understand control binding in c# programs and wonder if
>someone could clarify things for me.
>
> I have two related tables ...
>
> Parent: USERS (names)
> Child: USER_CONTACT (telephone numbers, etc)
>
> To the child table I've bound several textboxes as follows ...
>
> myTextbox.DataBindings.Add("Text", ds.USERS,
> "USER_USERCONTACT.FIELD_NAME");
>
> All of this works great. My problem is updating the datasource with
> changes made to the textbox values. Specifically, the routines below
> successfully pass updates to the datasource just once. After that, in
> spite of making more edits, the routines don't pass changes back to the
> datasource.
>
> Here are the main events in the code ...
>
> BindingContext[ds.USERS, "USER_USERCONTACT.FIELD_NAME"].EndCurrentEdit();
>
> daUSERS.Update(ds.USERS);
> daUSERS.Fill(ds.USERS);
>
> daUSERContact.Update(ds.USER_CONTACT);
> daUSERContact.Fill(ds.USER_CONTACT);
>
> Since my controls remain bound through the update and re­fill I assume
> that maybe "EndCurrentEdit()" has ended my editing session and, for
> additional editing, I need to somehow "begin edit." It's at this point
> that I realize the greater problem is my not having any idea what I'm
> doing!
>
> Thanks in advance for advice.
>



Re: Textbox DataBinding by Joe

Joe
Sun Aug 28 21:57:20 CDT 2005

Yes, the code executes when a Save button is pushed and is repeated the same
each time. So EndCurrentEdit is called each time the code runs. Without
EndCurrentEdit the textbox changes aren't saved even once.



Re: Textbox DataBinding by Cor

Cor
Mon Aug 29 01:17:32 CDT 2005

Joe,

Can you try this

> daUSERS.Update(ds.USERS);
ds.Users.Clear
> daUSERS.Fill(ds.USERS);
>
> daUSERContact.Update(ds.USER_CONTACT);
ds.Users_Contact.Clear
> daUSERContact.Fill(ds.USER_CONTACT);
>
I hope this helps,

Cor



Re: Textbox DataBinding by Bart

Bart
Mon Aug 29 06:37:42 CDT 2005

Hi,

"Joe Reggae" <JoeReggae@JoeReggae.org> wrote in message
news:11h44lhqi5ock77@corp.supernews.com...
>I don't fully understand control binding in c# programs and wonder if
>someone could clarify things for me.
>
> I have two related tables ...
>
> Parent: USERS (names)
> Child: USER_CONTACT (telephone numbers, etc)
>
> To the child table I've bound several textboxes as follows ...
>
> myTextbox.DataBindings.Add("Text", ds.USERS,
> "USER_USERCONTACT.FIELD_NAME");
>
> All of this works great. My problem is updating the datasource with
> changes made to the textbox values. Specifically, the routines below
> successfully pass updates to the datasource just once. After that, in
> spite of making more edits, the routines don't pass changes back to the
> datasource.
>
> Here are the main events in the code ...
>
> BindingContext[ds.USERS, "USER_USERCONTACT.FIELD_NAME"].EndCurrentEdit();

Not sure why it even works once, you should be calling EndCurrentEdit for
the entire row, not just for a column or field, so remove 'FIELD_NAME' :

BindingContext[ds.USERS, "USER_USERCONTACT"].EndCurrentEdit();

HTH,
Greetings


>
> daUSERS.Update(ds.USERS);
> daUSERS.Fill(ds.USERS);
>
> daUSERContact.Update(ds.USER_CONTACT);
> daUSERContact.Fill(ds.USER_CONTACT);
>
> Since my controls remain bound through the update and re­fill I assume
> that maybe "EndCurrentEdit()" has ended my editing session and, for
> additional editing, I need to somehow "begin edit." It's at this point
> that I realize the greater problem is my not having any idea what I'm
> doing!
>
> Thanks in advance for advice.
>



Re: Textbox DataBinding by Joe

Joe
Mon Aug 29 08:45:10 CDT 2005

That was the problem, my including the fieldname. Thanks for pointing that
out.