I have a user control that will dynamically add other user controls to it depending on user settings. I'm having problems adding controls using the overloaded LoadControl method.
I tried to do this:
ddControl = typeof(DropDownControl), new object[] { testData, FilterModel.Models[i] });
However, none of the controls in ddControl was initialized, and when I tried to set the data source to its contents, it exploded. I pass the model and data source to the constructor, which sets the properties, default values, etc. Should I create a LoadModel () method to load model values after creating the control, for example
(DropDownControl)LoadControl("~/WebUserControls/DropDownControl.ascx")
or can I do this through the constructor somehow, declaring it dynamically?
If this is unclear, let me know how I can do this. Thank!
source
share