two-way binding permitted?

dalem

Member
Joined
Apr 11, 2005
Messages
17
Programming Experience
10+
i've only been working with vb.net for about 3 months and have a question about data binding of controls. i'm able to download data from sql tables and bind to datagrid and navigate through datasets and dataviews. i'm able to update the original sql table with any changes (inserts, deletes, and modifications) all ok. but when i move from the bound datagrid to free-standing textboxes bound to a dataset, i have problems.

what i'm having trouble is a page that i have about 30 textboxes on. i had to use this instead of a datagrid and have them all set up as bound to a child table. the parent table is chosen in a combo box and then the child changes as the parent changes according to user selection in the combo box. all this works ok. both the parent and child table are part of the same dataset.

what i can't understand is how the underlying dataset that the textbox controls are bound to is updated. i can edit a textbox and the textbox will change its value ok. i navigate to another record and come back and the textbox retains the changed value ok. but when i test for the rowstate of the underlying dataset, no rows have changed. it seems that the dataset has not changed even though the textbox control's text value has changed. but i know this can not be, as how could the textbox control remember the changed value that i entered into it when i navigate back to that particular record.

i used the rowstatefilter.modified to check for any changes and even issued the dataset.acceptchanges but still no luck. the rowfilter.unchanged shows that all records are unchanged in the dataset.

basic question i have is "how do changes made in the bound textbox controls get communicated to the underlying dataset--is this automatic or is there some step i missed?"

any help in understanding this would be appreciated. thanks!

dale
 
You should not be calling AcceptChanges. If you are still doing that then that is probably the reason you are not seeing any modified rows. Every row has two sets of data: original and current. If they are different then the row has been Modified. If you call AcceptChanges then the original data is overwritten with the current and the row is considered Unchanged. Without the call to AcceptChanges then I would think that your DataSet should return rows when GetChanges is called because the data update should be automatic when data is bound to controls.
 
thanks for the reply. you're correct, i should not be calling acceptchanges and i only did this to test out the dataset after i was able to programmaticallly post changes to dataset. so, this was not the problem--i have not yet discovered what problem is but have found a temporary workaround. i wrote a global event handler to to check values on "enter" and "leave" for each control and then write the change to the dataset if there was a change. then i update the database and then accept the changes to dataset.

this works but obviously, i would like to know what how to get it work automatically with the bound controls. when i bind to a datagrid on other pages, it works as it should. i expect that eventually i will find out what the problem is and will be amazed at the mistake i am making.

thanks for your help.

dale
 
Back
Top