Problems with Nesting custom controls

N

Nauman

Hi All,

I've created two custom composite controls.
The first one is just a composition of a dropdown and a button. The user is
supposed to select a list item and click the button so that I can get the
value to perform server-side processing. This works just fine.

Where as the second one is a much larger control with many other controls
including the first one. I've instantiated the first control in the Second
one's CreateChildControls method. When I select a value in the embedded
(first control) control's dropdown list and click its associated button,
everything seems to work fine except that, I loose the selected index of the
nested(first control's) control's listbox.

PS: One more thing worth mentioning is that the list values for my first
control are populated in the OnLoad event of the control itself.

protected override void OnLoad(EventArgs e)
{
EnsureChildControls();
if(!Page.IsPostBack)
{
GetJobStates();
if(StateList != null)
{
ddlState.Items.Clear();
for(int iCtr = 0; iCtr < StateList.Length; iCtr++)
{
ddlState.Items.Add(StateList[iCtr]);
}
}
}
base.OnLoad (e);
}

If I remove the "if(!Page.IsPostBack)" check then the second control works
fine with the embedded first control, but the first control doesn't works
independently (without nesting/embedding)

Any Ideas???

Regards
Nauman
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top