Hi,

I have a custom user control (I'll call it ChildA) which contains a drop
down list, and this custom control is nested within another custom user
control (I'll call it ParentA).

I want to set a default value for ChildA (ie select an item in ChildA's
drop down list) from ParentA. I figured the best place to do that was in
ParentA's OnPreRender. However much to my surprise I found that ChildA's
Page_Load event hadn't been fired yet at this stage, hence ChildA's
Databind() method hadn't been called, hence there are no items in the
drop down list to select.

I've made a workaround by calling ChildA.Databind() from ParentA but I
was wondering is there a better way, since I had to create a flag within
ChildA to ensure that Databind() wasn't called twice (once by ParentA if
it want's to set a default value and once by ChildA's Page_Load event).

Is there a better way? Should I not be doing this in the OnPreRender
method?

TIA

Andy

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to