Dynamic PlaceHolder


I need to create a placeholder dynamically, containing dynamical content. If I create the placeholder at design time everything is ok. If I do create a placeholder and add the table with my data to it, it doesn't show to screen. What's wrong?

protected void Page_Load(object sender, EventArgs e)

            PlaceHolder aPlaceHolder = new PlaceHolder();
            aPlaceHolder.Visible = true;

Who is Participating?
NullableConnect With a Mentor Commented:
you MUST add Your PlaceHolder Object in Page.Controls
Kevin CrossChief Technology OfficerCommented:
It doesn't know where to put it.  Usually I will put in a placeholder in design time and then add the controls to it dynamically.  You could place it where it should be and make it Visible = false.

You could still dynamically create PlaceHolder objects and just use your first one for where to place on page say if you have multiple placeholder objects you are creating for some reason.

Otherwise, the one on the design surface should be able to take in as many controls as you want.

I have never tried it, but guess you could try to add this to another layout style control like a panel or something.
Kevin CrossChief Technology OfficerCommented:
Ah, see how little I do with design.  Guess I should just go back to my server/business objects little hole. :) Nice answer Nullable.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

i dont see your answer mwvisa1

Kevin CrossChief Technology OfficerCommented:
I answered above, but yours is correct which is why I was giving you kudos!
sorry i use bad VERB ( SEE )
i must use ( seen )(past)

my english is bad :(
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.