Finding Dynamic controls
HI, I am adding many dynamic controls to a web form in the Initialization event. Later in the Page Load event I want to populate those controls. And on PostBacks I need to read those controls. I give each control a unique ID as it is added. How do I directly access the properties and methods of those controls? I can use nested âFor Eachâ loops with testing to determine the controls ID but this is very messy. If I know the control ID I want to access, how do I get to its properties?
Here is the example. I have a Placeholder(ID = plc1) on a web form. In that place holder is a Panel, the panel contains a Table, the Table has a rows, Each row has cells, and within a cell I want to access a Drop Down list with an ID of âddl1â. I want to add items to ddl1 and later read the selected text.
Below is my best guess. What should it really be?
Dim ctl as DropDownList = me.plc1.findcontrol(âddl1â)
strResult = ctl.text