Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updates Via Textbox Bound to a Dataset Field

Status
Not open for further replies.

markk609

Programmer
Feb 19, 2005
11
US
I have placed both a group of textbox controls and a datagrid control on a Windows form. The fields in the datagrid are the same as those which populate the textbox controls. This form connects to a SQL Server database via Web services. All of the form's controls (both text boxes and datagrid) become fully populated when the form is opened. I can make changes to data in the datagrid and successfully save them back to the SQL Server database via an update Web method. However, I cannot save changes made in the text boxes. I am puzzled because both the text boxes and the datagrid are bound to the same dataset. Changes to that dataset are apparently only recognized and processed if they are made in the datagrid control. Can anyone suggest what might be at play here?
 
If a textbox is bound to a dataset and when modifications are made to these textboxes the RowState of the Datarow doesn’t change but RowVersion changes. So when Datasets HasChanges method is called nothing shows up as changed.

One way to resolve this issue is to use BindingContext of the Container Control(UserControl,Form etc) to call EndCurrentEdit or CancelCurrentEdit as required. This sets the RowState to appropriate values. Then you can update the database as the dataset will have proper rowstate values.

Also look up CurrencyManager,BindingManagerBase in msdn.

Hope it helps

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top