hi ramesh thank for reply but i want to create dynamic but not in page load event . i want to create but in tree view template when its expand event fire i have try to create button or any control but when next any event fire all dynamically generated control get remove i cant handle it state
You can create dynamic control in Page Load or Page Init events only. Otherwise they won't be retained in ViewState and vanished between postback.
If you want to create a dynamic control when tree view is expanded, then check the value of Request.Params["__EVENTTARGET"] in the page load event and create dynamic control in the page load event based on that.
The Request.Params["__EVENTTARGET"] may have your tree node information if the tree view node post back the page.
I have posted the tested version of the code(except last line in page load event which was missed in copy/paste).
Even if you are using place holder, then you should add dynamic controls only page load or page init events. Adding dynamic controls in child control's event like button_click will be vanished between postback.
also i want number of dynamic control add in tree view instead of tree node also maintain its command argument and some info for nest processing i.t node contain button or some lebal or check box
label show node info
check box contain some other operation
button trigger some other
when perticular button in tree view trigger not only its state mantian but also all open node contain dyanamic control also maintain