473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databinding takes high time

Hi,
In my usercontrol I bind the BindingSource I pass via property to all
the control inside the usercontrol.

For example

Control ctl=new TextBox();
ctl.DataBinding s.Add("Text", binding, prop, false,
DataSourceUpdat eMode.OnPropert yChanged);

via ANTS Profiler I see that it takes so much time and the UI seems
freeze (I have at least 10 controls to bind)

The behaviour slow down if I bind a combobox...

cmb.ValueMember = "Id";
cmb.DisplayMemb er = "Etichetta" ;
cmb.DataSource = binding;
cmb.DataBinding s.Add("Selected Item", binding, prop, true,
DataSourceUpdat eMode.OnValidat ion, null);

at least 0,7 seconds for each control.

What is wrong? How can I speed up the binding task?

Thanks
Mauro
May 31 '07 #1
3 2824
Mauro,

There isn't much you can do, really. Remember, data binding uses
reflection to perform its operations, and that is inherently slower than
other methods.

The two things I can think of to speed up binding is to implement the
INotifyProperty Changed interface, as it will not use reflection for change
notification on your type (assuming you are supporting it).

Second, for your properties that you are bound to, just make sure that
you are not doing a lot of heavy work in them (but that should be obvious).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mauro D." <ma************ *****@tinspam.i twrote in message
news:_S******** ***********@twi ster2.libero.it ...
Hi,
In my usercontrol I bind the BindingSource I pass via property to all the
control inside the usercontrol.

For example

Control ctl=new TextBox();
ctl.DataBinding s.Add("Text", binding, prop, false,
DataSourceUpdat eMode.OnPropert yChanged);

via ANTS Profiler I see that it takes so much time and the UI seems freeze
(I have at least 10 controls to bind)

The behaviour slow down if I bind a combobox...

cmb.ValueMember = "Id";
cmb.DisplayMemb er = "Etichetta" ;
cmb.DataSource = binding;
cmb.DataBinding s.Add("Selected Item", binding, prop, true,
DataSourceUpdat eMode.OnValidat ion, null);

at least 0,7 seconds for each control.

What is wrong? How can I speed up the binding task?

Thanks
Mauro
May 31 '07 #2
I'm not quite sure why it is *so* slow here, but if Nicholas is
correct (and reflection is the lag), you could try the following; this
improves the reflection -component-model (i.e. what data-binding
uses) performance by a factor of roughly 180. Which is nice ;-p

http://www.codeproject.com/csharp/Hy...Descriptor.asp

Marc
May 31 '07 #3
Nicholas Paldino [.NET/C# MVP] wrote:
Mauro,

There isn't much you can do, really. Remember, data binding uses
reflection to perform its operations, and that is inherently slower than
other methods.

The two things I can think of to speed up binding is to implement the
INotifyProperty Changed interface, as it will not use reflection for
change notification on your type (assuming you are supporting it).

Second, for your properties that you are bound to, just make sure
that you are not doing a lot of heavy work in them (but that should be
obvious).

My class already implement the INotifyProperty Changed interface...

My problem is not linked with a change in the property value but only in
the "startup time" of the binding.

Mauro
May 31 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1337
by: RvGrah | last post by:
This code: private void GetPlans(){ dt = dt.Clone(); //New object? cn.Open(); SqlDataReader drd = cmdGetPlans.ExecuteReader(); if (drd.HasRows){ while (drd.Read()){ dt.Rows.Add(new Object {drd.ToString(),//where the problem happens
0
1309
by: Andrew Ducker | last post by:
Am I right in thinking that databinding only really takes effect when a control is made visible? The reason I ask is that the application I'm working on consists of a collection of Panels, each of which shows nothing but a "please wait" message until the business service it depends on returns. When it has returned it fills in the panel's controls, and they each make a note of their initial values (so that the form can tell if any...
0
1300
by: Simon Gregory | last post by:
I am currently attempting to figure out how the new databinding stucture works in ASP.NET 2.0 after working with v1.0 & v1.1 for several years. It seems that if you wish to do set up databinding at Design Time, you are restricted to using one of the 5 xxxDataSource controls. The data in our websites are usually obtained via a set of webservices and are contained in a set of strongly typed relational DataSets.
8
2185
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
5
12530
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I update the datasource - awesome, but I have an issue with updating from a different thread. Here is my datasource, a person class that raises the PropertyChanged event: class Person : INotifyPropertyChanged {
1
1747
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following simple statements to actually generate something at design-time: gridView = new GridView(); gridView.AutoGenerateColumns = true; gridView.DataSource = ; gridView.DataBind(); I have tried everything I could think of, or read about in four books...
2
3266
by: cjard | last post by:
I ask, because I have a textbox bound to a bindingsource, which is bound to a datatable(row) The datatable is typed, and hence exports a Property called Column1 I added another property to the datatable by editing the partial class, and Called it ColumnX - it simply returns "Hello World" all the time Then I tried to bind my textbox to it, editing the binding for .Text from xyzBindingSource - Column1
2
1282
by: Sebastian | last post by:
Hi, I want to skin the templates of an asp:DataList. So I have to do data binding in the skin (I didn't find another comfortable way to do that). As soon there's a <%# ... %tag in the skin, VS seems not to recognize the skin file anymore. The property editor displays SkinID grayed out, and I cannot select anything. Interestingly, I can enter the SkinID by hand, and page rendering actually works!
3
3269
by: David Smith | last post by:
I have an app that shows the time it takes to execute a search, much like SQL Management Studio, but the app behaves as though the System.Windows.Forms.Timer gets blocked while binding the results to the grid. As you might expect, I execute the search in the background but I have to return to the UI thread to bind the results. While databinding, it appears as though the Timer.Tick event never gets fired, so my timer freezes at the time before...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.