By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,894 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,894 IT Pros & Developers. It's quick & easy.

C#-Form: Databound controls repeatedly get values from datasource on control change

P: 1
I have a windows client database management application written in C# that connects to remote web services to do all the heavy work. The thin-client app uses strong typed datasets, all maintained at the web service, with a web reference to those datasets via exposed [WebMethod]s on the web service.

The client app has a series of windows forms designed to manage particular types of data. For example, there's a manage users form. On each of these forms, I have added a dataset and databinding object (by dragging the dataset from the "Show Data Sources" window). When doing this, Visual Studio drops controls onto the form automatically that match up with the fields in the datasets, but I typically delete all these controls after dragging/dropping, and create the controls that I want and then edit the DataBindings property for each control to assign it back to a field in the dataset. I do this with all kinds of controls, including TextBoxes, masked edit boxes, checkboxes, and datetimepicker controls.

Several of my datasets have large numbers of fields (over 100), so I even employ the tab control to have some fields displayed on some tabs and some on others.

My problem is this: on several of my windows forms, some (unknown) event seems to be triggered when a value is changed in any of the databound controls on a form, causing the application to re-get every field from the underlying datasource and apply it to all the controls on the form, except for the field being changed, for which the control's value is first set into the underyling datasource. Nothing bad happens to the data in the datasource or the data in the controls (ie, it's not like a user's data is changing).... the bad thing is that there is a visible lag of about a second on these forms with 100+ fields in the datasource, because it goes thru every field in the datasource and updates every control on the form, any time you change a single piece of data on the form. So, even when just clicking a checkbox, the user is forced to wait about a solid second and a half before they can do anything else (like click a different checkbox).

There are no events defined on any of these controls, so there's nothing to put a breakpoint on. Even so, I CTRL+BREAK the application while running in the Visual Studio IDE and then will change a field (perhaps typing a single value in a textbox, or putting a check in a checkbox). When I type the value/make the check, all is well. But as soon as a tab or click away from that control, the code goes into the automatically generated References.cs (the file storing all the strongly definitions from the Web References) and proceeds to execute a "get" from every WebReference.dsDataSet.DataTable field in the bound dataset.

This happens any time I change any control's values where the control is bound to the tABLENAMEBindingSource, and is just killing my application's performance.

It doesn't seem to be happening on all the forms in my application, but it is happening on some of them. I've compared everything I can compare in the application, including the cs codebehind, the properties on all the controls (and the windows forms itself), and the windows-generated Designer.cs, and can't see what might be causing this repeated re-binding / re-committing.

I've tried using SuspendBinding, and when I execute that, every control simply blanks out.

I don't know what to do to get it to stop constantly going into References.cs and executing a get operation on every bound field in the dataset and updating the controls on screen, but that's what I need to do make my application usable.

Any help you can provide would be greatly appreciated.

Jan 20 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.