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

B

bogdan

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
 
T

Teemu Keiski

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top