c# - radiobuttonlist in updatepanel both dynamically created don't retain value on postback -


i'm dynamically creating controls on page (aspx) using code below, when asynchronous postback triggers radio button doesn't retain it's selection , method uptheup doesn't called. i'm guessing it's view state not returning values, thought if control id same , it's created in page_init in page_load value should automatically set view state??

what want if selects no textbox become visible. control ids set database , same each time loads code used several times (i've replaced ids easy reading below)

the following called page_init

radiobuttonlist rbtnl = new radiobuttonlist();                         rbtnl.id = "rbl_1";                         rbtnl.items.add("yes");                         rbtnl.items.add("no");                         rbtnl.autopostback = true;                         rbtnl.enableviewstate = true;                         rbtnl.selectedindexchanged += new eventhandler(uptheup);                         rbtnl.clientidmode = system.web.ui.clientidmode.autoid;                         scriptmanager1.registerasyncpostbackcontrol(rbtnl);                          textbox tbx = new textbox();                         tbx.id = "tb-1";                         tbx.cssclass = "form-control";                         tbx.visible = false;                          updatepanel upx = new updatepanel();                         upx.id = "up-1";                         upx.contenttemplatecontainer.controls.add(rbtnl);                         upx.contenttemplatecontainer.controls.add(tbx);                         upx.updatemode = updatepanelupdatemode.always;                         upx.enableviewstate = true;                         upx.childrenastriggers = true;                           plcevalbody.controls.add(upx); 

ok code fine , works well, issue me assuming ids weren't issue - - never use $ in control id's. i'd used separate 2 sections of id , not valid.


Comments