Which event to handle for web part refresh? RRS feed

  • Question

  • I have several web parts on a page with the second web part connected to the first such that when the user selects a record in the first part, the records shown in the second part are filtered to those related to the first selection.  I need to catch when there are NO records for a selection and add a default record.  I'm assuming I can do that with an event handler by writing the code with Visual Studio. I know the second web part (list) is being filtered by the selection in the first but the part has to be refreshed somehow.  So which event do I need to "handle"?  Since this has to be done with each selection, do I overwrite the pre-render or the post back or what? 
    Thursday, September 1, 2011 8:27 PM


  • Hi,

    You do not need to worry about the refresh of web parts. For example, when you click a button in webpart1, a full postback will be triggered and everything in this page will refresh. What you need to do is trying to notice the webpart2 that the webpart1 is changed and webpart2 should load some data based on webpart1.

    An elegant workaround is to create a connection between these web parts in SharePoint. We called webpart1 "Provider" and webpart2 "Consumer".

    Here are some examples, you can check it:

    Hope this can help.

    • Marked as answer by Zizhuoye Chen Friday, September 9, 2011 9:02 AM
    Tuesday, September 6, 2011 3:17 AM