locked
Event firing order?? RRS feed

  • Question

  • User-1450176746 posted

    Hi,

    I am writing a new custom control to provide a wrapper around a Flash control. My control inherits from DataBoundControl. Databinding code comprises PerformSelect and PerformDataBinding and I am retrieving the data ok. My problem arises in that I need to output some javascript which I naturally do in the overridden OnPreRender. This javascript needs to have some of the data values embedded, only when I checked the source to checkout my render javascript none of my data values were there. When I provided some break points in my code I notice OnPreRender was firing before PerformDataBing?? How can this be? Is there anyway I can force the data to bind before my PreRender method is executed??

     Regards,

     

    Monday, July 28, 2008 9:18 AM

Answers

  • User-1573490007 posted

    PerformDataBind will be one of the last things to happen. It is a little bit like CreateChildControls for CompositeControls.

    If you need values from the databinding step, you must call EnsureDataBound. If the control was already databound (because the caller forced it, for example, by calling DataBind), it will do absolutely nothing. But if it wasn't, it will, well, ensure that the databound stuff is done when you need it. It is fairly common to call EnsureDataBound in the pre-render step.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 28, 2008 9:56 AM

All replies

  • User-1573490007 posted

    PerformDataBind will be one of the last things to happen. It is a little bit like CreateChildControls for CompositeControls.

    If you need values from the databinding step, you must call EnsureDataBound. If the control was already databound (because the caller forced it, for example, by calling DataBind), it will do absolutely nothing. But if it wasn't, it will, well, ensure that the databound stuff is done when you need it. It is fairly common to call EnsureDataBound in the pre-render step.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 28, 2008 9:56 AM
  • User-1450176746 posted

     

    Of course! I've used EnsureDataBound() before, but not in this context! Thanks for your help!
    Monday, July 28, 2008 10:05 AM