Bindingd Dataset to Textbox appears flawed. 
Author Message
 Bindingd Dataset to Textbox appears flawed.

It appears to me that binding to textboxes with a dataset is iffy at best. I
have a  test project that shows what I have been looking at. This is a set
of screens that accesses the Pubs/Publishers table. I will be glad to send
this project (30M zipped) to anyone who wants to take a look at it, just let
me know.

What I have found is this:
Form1: straightforward grid tied to all data in the table, seems to work ok.

Form2: grid with an adapter that loads only a single row, seems to work ok
too.

Form3: textbox implementation with all boxes bound to dataset. Changes to
the State field (or any field) are not saved unless you  update the value in
the dataset in txtState_Validating. If you update the value in
txtState_textchanged then you get strange behavior (see comments in code)

DataForm1: illustrates binding to textboxes as the DataForm wizard sees it.
This seems to work but you must move from a changed row to another row
before clicking update or the changes don't take.

Form4: A repeat of Form3 but now I have added a line
Me.BindingContext(PublishersDS1, "publishers").EndCurrentEdit()
to the save button. This is what I noticed the DataForm1 wizard generated
code was doing when you moved from row to row. This now works without any
binding code in _validating or _textchanged.  I would love to have an
explanation for this!

Form5: A repeat of Form3 but with binding not set on the "State" field. I
have handled the binding with code in  _validating and _textchanged. This
also seems to work fine.

My conclusion: I think one (or more of the following is true:)

The binding to textbox has a bug.
The explanation of what is going on is inadequate.
MS needs to provide real world examples of this stuff.
Handling the binding with my own code seems safest for now as I have no idea
what the BindingContext...EndCurrentEdit is doing.
I still haven't got a clue what I am doing.

--
Barry Fitzgerald



Fri, 30 Jan 2004 02:46:47 GMT  
 Bindingd Dataset to Textbox appears flawed.
Check out the .NET QuickStart tutorials.  The MasterDetails and
CustomerDetails samples in the Windows Forms section do quite a bit of
binding and even go so far as to show how you would bind to data retrieved
from a WebService and then update the data in the database using the same
WebService.  Maybe there will be some more explanation there.

--
Justin Rogers



Quote:
> It appears to me that binding to textboxes with a dataset is iffy at best.
I
> have a  test project that shows what I have been looking at. This is a set
> of screens that accesses the Pubs/Publishers table. I will be glad to send
> this project (30M zipped) to anyone who wants to take a look at it, just
let
> me know.

> What I have found is this:
> Form1: straightforward grid tied to all data in the table, seems to work
ok.

> Form2: grid with an adapter that loads only a single row, seems to work ok
> too.

> Form3: textbox implementation with all boxes bound to dataset. Changes to
> the State field (or any field) are not saved unless you  update the value
in
> the dataset in txtState_Validating. If you update the value in
> txtState_textchanged then you get strange behavior (see comments in code)

> DataForm1: illustrates binding to textboxes as the DataForm wizard sees
it.
> This seems to work but you must move from a changed row to another row
> before clicking update or the changes don't take.

> Form4: A repeat of Form3 but now I have added a line
> Me.BindingContext(PublishersDS1, "publishers").EndCurrentEdit()
> to the save button. This is what I noticed the DataForm1 wizard generated
> code was doing when you moved from row to row. This now works without any
> binding code in _validating or _textchanged.  I would love to have an
> explanation for this!

> Form5: A repeat of Form3 but with binding not set on the "State" field. I
> have handled the binding with code in  _validating and _textchanged. This
> also seems to work fine.

> My conclusion: I think one (or more of the following is true:)

> The binding to textbox has a bug.
> The explanation of what is going on is inadequate.
> MS needs to provide real world examples of this stuff.
> Handling the binding with my own code seems safest for now as I have no
idea
> what the BindingContext...EndCurrentEdit is doing.
> I still haven't got a clue what I am doing.

> --
> Barry Fitzgerald




Fri, 30 Jan 2004 03:00:03 GMT  
 Bindingd Dataset to Textbox appears flawed.
If you want to know what EndCurrentEdit does, I'll tell you. You have
selected one of the rows of the table to edit. All the data is shown in the
textboxes. You edit the fields you wish, but during that time, the row is in
editing state. If you want to save them, you have to end this editing with
EndCurrentEdit. When you change selected row, it automatically call it.

Here's a tip about binding. If you save data back to the datasource when you
change row, close the form or anything, and you call EndCurrentEdit, if you
close the form, the control you just edited who still have the focus will
not save because it's still in editing and the data haven't been validated.
When you close, you can change the focus to another control before saving.



Quote:
> It appears to me that binding to textboxes with a dataset is iffy at best.
I
> have a  test project that shows what I have been looking at. This is a set
> of screens that accesses the Pubs/Publishers table. I will be glad to send
> this project (30M zipped) to anyone who wants to take a look at it, just
let
> me know.

> What I have found is this:
> Form1: straightforward grid tied to all data in the table, seems to work
ok.

> Form2: grid with an adapter that loads only a single row, seems to work ok
> too.

> Form3: textbox implementation with all boxes bound to dataset. Changes to
> the State field (or any field) are not saved unless you  update the value
in
> the dataset in txtState_Validating. If you update the value in
> txtState_textchanged then you get strange behavior (see comments in code)

> DataForm1: illustrates binding to textboxes as the DataForm wizard sees
it.
> This seems to work but you must move from a changed row to another row
> before clicking update or the changes don't take.

> Form4: A repeat of Form3 but now I have added a line
> Me.BindingContext(PublishersDS1, "publishers").EndCurrentEdit()
> to the save button. This is what I noticed the DataForm1 wizard generated
> code was doing when you moved from row to row. This now works without any
> binding code in _validating or _textchanged.  I would love to have an
> explanation for this!

> Form5: A repeat of Form3 but with binding not set on the "State" field. I
> have handled the binding with code in  _validating and _textchanged. This
> also seems to work fine.

> My conclusion: I think one (or more of the following is true:)

> The binding to textbox has a bug.
> The explanation of what is going on is inadequate.
> MS needs to provide real world examples of this stuff.
> Handling the binding with my own code seems safest for now as I have no
idea
> what the BindingContext...EndCurrentEdit is doing.
> I still haven't got a clue what I am doing.

> --
> Barry Fitzgerald




Fri, 30 Jan 2004 20:04:47 GMT  
 Bindingd Dataset to Textbox appears flawed.
In my case there is only one row in the dataset so I am not changing rows. I
also did not issue any kind of any begin edit. Is begin edit automatically
started when a row is selected?

Barry


Quote:
> If you want to know what EndCurrentEdit does, I'll tell you. You have
> selected one of the rows of the table to edit. All the data is shown in
the
> textboxes. You edit the fields you wish, but during that time, the row is
in
> editing state. If you want to save them, you have to end this editing with
> EndCurrentEdit. When you change selected row, it automatically call it.

> Here's a tip about binding. If you save data back to the datasource when
you
> change row, close the form or anything, and you call EndCurrentEdit, if
you
> close the form, the control you just edited who still have the focus will
> not save because it's still in editing and the data haven't been
validated.
> When you close, you can change the focus to another control before saving.



> > It appears to me that binding to textboxes with a dataset is iffy at
best.
> I
> > have a  test project that shows what I have been looking at. This is a
set
> > of screens that accesses the Pubs/Publishers table. I will be glad to
send
> > this project (30M zipped) to anyone who wants to take a look at it, just
> let
> > me know.

> > What I have found is this:
> > Form1: straightforward grid tied to all data in the table, seems to work
> ok.

> > Form2: grid with an adapter that loads only a single row, seems to work
ok
> > too.

> > Form3: textbox implementation with all boxes bound to dataset. Changes
to
> > the State field (or any field) are not saved unless you  update the
value
> in
> > the dataset in txtState_Validating. If you update the value in
> > txtState_textchanged then you get strange behavior (see comments in
code)

> > DataForm1: illustrates binding to textboxes as the DataForm wizard sees
> it.
> > This seems to work but you must move from a changed row to another row
> > before clicking update or the changes don't take.

> > Form4: A repeat of Form3 but now I have added a line
> > Me.BindingContext(PublishersDS1, "publishers").EndCurrentEdit()
> > to the save button. This is what I noticed the DataForm1 wizard
generated
> > code was doing when you moved from row to row. This now works without
any
> > binding code in _validating or _textchanged.  I would love to have an
> > explanation for this!

> > Form5: A repeat of Form3 but with binding not set on the "State" field.
I
> > have handled the binding with code in  _validating and _textchanged.
This
> > also seems to work fine.

> > My conclusion: I think one (or more of the following is true:)

> > The binding to textbox has a bug.
> > The explanation of what is going on is inadequate.
> > MS needs to provide real world examples of this stuff.
> > Handling the binding with my own code seems safest for now as I have no
> idea
> > what the BindingContext...EndCurrentEdit is doing.
> > I still haven't got a clue what I am doing.

> > --
> > Barry Fitzgerald




Sun, 01 Feb 2004 20:06:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Deleted records appear in dataset

2. New Column not appear in Dataset.

3. How to make first letter of textbox appear only

4. Selecting textboxes in order the appear in doc

5. Can't get cursor to appear in textbox

6. filling textbox with data from a dataset

7. Getting values from dataset to a textbox

8. Filling Dataset and textbox through code ?

9. setting textbox maxlength automatically using sql dataset schema???

10. Masking a password textbox to appear as all *****

11. An Unwanted Comma appears in TextBox

12. MS's Regular Expression component is flawed?

 

 
Powered by phpBB® Forum Software