Last Databound Control (like textbox) Edited Not Saved

Last Databound Control (like textbox) Edited Not Saved

Post by Brian Kore » Wed, 24 Sep 2003 12:04:16


I wanted to make this available to others in the same boat - it took
me half a day to figure this out and I could not find it explicitly
stated anywhere (newsgroups, web or MSDN) though it is alluded to.

My situation - C#, SQL2000 using Windows forms

On my databound windows form (single record display), on edit the last
user control changed (textbox, combobox, checkbox, etc) was not being
updated without that last control losing focus (in fact several posts
across groups mention this as a solution, as well as subclassing
controls to utilitze TextChanged event or changing to another row if
using a datagrid).

The problem was I was posting the row changes to the dataset using the
EndEdit() method (Dataset.TableIndex.RowIndex.EndEdit()).

If you use the EndCurrentEdit() method (this.BindingContext[Dataset,
"Tablename"].EndCurrentEdit(), this particular issue goes away
(example - editing one control on your form without it losing focus,
then updating is now possible).

Fair warning - during my newsgroup travels some guy from MS (late 2001
post) advised that this method only be used with "complex" controls
such as datagrids - otherwise he recommended EndEdit(). Until I find
a downside to EndCurrentEdit(), it is my current choice.

If people with more experience (I have virtually none) with ADO .NET
would like to chime in about the downsides of EndCurrentEdit(), please
do so.

Brian
 
 
 

1. Databound textbox once edited cannot make blank again

2. Changes to databound control not being saved


I'm using vb .net 2003 and MS SQL server DE. I'm using the ADO .net SQL data
controls (SQLConnect, SQLDataAdapter and a dataset). I'm able to retrieve
data from SQL server and populate a form to some databound text boxes.
However, when I make changes to the text boxes and try to save them back to
SQL server using the sqldataadapter.update(dataset) method they aren't being
saved to the SQL database. I'm working off an example from a book and the
only difference is that the book shows changes made to a datagrid rather
than a databound text box.

Any help is appreciated.


I have a simple from with text box controls bound to

3. Showing Last Saved by or Last Edited by information

4. _base.vcx edit does not change textboxes generated by Forms control toolbar.

5. databound textbox not working

6. Textbox text property not populating in a bound textbox until control is shown

7. To control textbox according to label values ( label should be controlled from another textbox )

8. Databound Fields are not saved

9. Save Last USERFORM Textbox State

10. databound controls not working - Error 713

11. Databound control not updating user object on form closing ('X

12. Databound controls do not work when published to a production serv

13. Databound control not updating user object on form closing ('X')

14. Databound control does not appear upon entry