When does control data binding occur in a life cycle of a page?

Discussion in 'ASP .Net' started by bogdan, Mar 20, 2008.

  1. bogdan

    bogdan Guest

    I need to execute some code _after_ page controls are bound to data (e.g.
    DropDownList). I could probably handle DataBound events for each control.
    But if I wanted to place the code in a page handler, where would I put it?
    Does Page_Load() event is raised after or before control data binding takes
    place?

    Thanks,
    Bogdan
    bogdan, Mar 20, 2008
    #1
    1. Advertising

  2. bogdan

    Teemu Keiski Guest

    Hi,

    do you mean binding done by data source controls? If you bind manually that
    of course happens whenever you call dataBind() for the control, so when that
    happens is up to you, the page developer.

    Yes you could do that with DataBound event. Data source conrreols also have
    their own events like SqldataSource's Selected event

    Quite common is that on first request, control are bound at PreRender stage
    but on postback they must then be populated before Page_Load because
    postback data is already loaded before that, so data in lists etc must exist
    so that state change based on postback data, can be made.

    SqldataSource for example gets its select operation called in PreRender by
    the databound controls.


    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net

    "bogdan" <> wrote in message
    news:...
    >I need to execute some code _after_ page controls are bound to data (e.g.
    >DropDownList). I could probably handle DataBound events for each control.
    >But if I wanted to place the code in a page handler, where would I put it?
    >Does Page_Load() event is raised after or before control data binding takes
    >place?
    >
    > Thanks,
    > Bogdan
    >
    >
    Teemu Keiski, Mar 20, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura
    Replies:
    4
    Views:
    443
    Hans Kesting
    May 6, 2004
  2. Griff

    Control events - page life-cycle

    Griff, Sep 20, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    915
    Griff
    Sep 20, 2006
  3. lander
    Replies:
    5
    Views:
    2,521
    Mark Rae [MVP]
    Mar 3, 2008
  4. TS
    Replies:
    3
    Views:
    1,788
  5. TS
    Replies:
    5
    Views:
    851
Loading...

Share This Page