I would not do it dynamically, since winning is not worth the complex or perceived savings. Also, if you set visible = false , keep in mind that the view state is still enabled for your controls. If you are worried about back and fourth data and are dealing with a large view, be sure to turn off the viewstate for all controls or for the parent panel that contains them. You will have the same inconvenience to maintain your state during postback, as it happens dynamically.
Also, doing this non-dynamically is a lot easier to keep up with the next guy working with code. The layout is clear and easier to visualize than trying to figure out which code when puts where.
Creating controls dynamically does not really give you anything in common, except for an exception from the viewstate and possibly a sloppy processing server. I think it will be difficult for you to even measure most of the noticeable difference, even when loading between them, the non-viewstate control and the overhead associated with dynamically adding them as needed.
Finally, it’s easier not to do it dynamically, so why not take the simplest route and see if this is a problem. If this becomes a problem, check it where necessary.
source share