0
votes

A while ago I started working with SharePoint Web Parts (Visual Web Parts). When I was building my first Web Parts I did all my data-binding on PageLoad().

Now I've started to build a custom-filter web part which sends filter-options to another web part through a communication interface. Basically, it works fine but I noticed that the method for receiving the filter-options (ConnectionConsumer) ran after the PageLoad. So if I’m using the filter-web part the DataBinding runs twice (on PageLoad and after receiving the FilterData so the filter can take effect).

So I guess that there is a better place to bind the data to my web part apart from PageLoad.

And now my question: Where should I bind the data?

2

2 Answers

1
votes

The rule of thumb is to bind data just before rendering. Override PreRender event instead and do the binding logic there.

0
votes

I had a similar issue where my page load was being fired twice. I just commented out the "Handles Me.Load" and it worked fine. If you set AutoEventWireup to true, make sure that you do not also manually attach page event handlers to events. If you do, handlers might be called more than one time. Check this link on MSDN for more details: http://msdn.microsoft.com/en-us/library/system.web.configuration.pagessection.autoeventwireup(v=vs.110).aspx