locked
CompositeDataBoundControl concept doubt RRS feed

  • Question

  • User-1824576983 posted
    Hello,

    I'm trying to code a custom server control that inherits from CompositeDataBoundControl but I think I'm missing some concept here.

    My problem is the following: when page posts back, this is what I think is happening

    LoadState
    ...
    CreateChildControls
    ...
    PreRender
    ...
    SaveState

    So the child controls properly save their state. Depending on some page states, I have to modify some properties of the child controls
    (for instance hide some controls, change colors, etc.), but so far everything is okay.
    The thing I don't understand is that it's possible the datasource object is modified due to an event in the page. So now I need to rebind
    the compositeControl. But in doing so, I loose all the state of childcontrols:

    LoadState
    ...
    CreateChildControls
    ...
    Modify ChildControl Properties
    ...
    Modify DataSource object
    ...
    CreateChildControls (dataBinding = true). The thing here is that no LoadControlState/SaveControlState is called, so I loose child
    controls states and replace by defaults
    ...
    SaveState

    How do I keep my childcontrols state? What's the missing piece of this model?

    Thanks in advance.
    Thursday, August 28, 2008 11:39 AM

Answers

All replies

  • User-16411453 posted

     No, you have the sequence incorrect.

     Peter Butcher posted the load chart in one of his post withing the last 30 days. You can private message him for the link, or click on his name and hunt it down.
     

    I think this is more correct, I don't know about the correct states, but I think it's after OnInit

    OnInit

    Load State 

    CreateChildControls

    OnLoad

    Render - Paint the control to the screen, or generate asp.net web markup

    SaveState 

    Thursday, August 28, 2008 2:59 PM
  • User481221548 posted

    Hi there

    @jkirkerx
    Peter Bucher :-)

    @liandrillo
    Look at the MS Sites on this Link:

    And also this picture that shows the most used steps in the cycle:

    There are also Methods where called more than once and depending on some properties of your Control. CreateChildControls is such a Method.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 31, 2008 10:58 PM
  • User-16411453 posted

    Peter,

    Thanks for the assist on the post. I knew you were out there somewhere!

    Kirker

     

    Monday, September 1, 2008 2:04 PM