views:

38

answers:

1

Hello I built a webusercontrol in asp.net which contains a databound dropdown. When I directly put this control into a webform it runs well. But if I try to add this control as childcontrol to another control at runtime

Childcontrol childcontrol = new Childcontrol ();
maincontrol.controls.add(childcontrol)

, the dropdown of the childcontrol is not instatiated (is null) so that I run in an exception by trying to bind the data to the dropdown.

A: 

If this is a user control (you have an ascx file?) then you need to use LoadControl so that ASP.NET instantiates the objects.

Bryan