c# - No controls found in PlaceHolder when adding programmatically -
i have weird issue i'm not sure on how resolve. i'm trying values controls when clicking button. controls in web user control load control many times need (each control value returned public properties have assigned). added placeholder. first add controls clicking button:
protected void addcontrols { mymywebusercontrol custinfo = (mywebusercontrol)loadcontrol("mywebusercontrol.ascx"); (int c = 0; c <= 10; c++) { custinfo.id = "customctrl" + c + 1; myplaceholder.controls.add(custinfo); } }
i enter info controls displayed , use second button values , save info
protected void btngetvaluefromcontrols_click(object sender, eventargs e) { foreach (mywebusercontrol ctrl in myplaceholder.controls) { myobj.name = ctrl.name; myobj.surname = ctrl.surname; } savecustomer }
the count in myplaceholder 0.
i have tried adding code test postback @ page load
if(!(page.ispostback)) { addcontrols(); }
which doesn't resolve.
Comments
Post a Comment