Solved

Dynamic PlaceHolder

Posted on 2008-10-28
6
1,401 Views
Last Modified: 2013-12-17
Hello.

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.Controls.Add(MyTable);
            aPlaceHolder.Visible = true;

   }
0
Comment
Question by:ziggie301
  • 3
  • 3
6 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22827804
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.
0
 
LVL 1

Accepted Solution

by:
Nullable earned 500 total points
ID: 22827805
HI
you MUST add Your PlaceHolder Object in Page.Controls
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22827822
Ah, see how little I do with design.  Guess I should just go back to my server/business objects little hole. :) Nice answer Nullable.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:Nullable
ID: 22827873
i dont see your answer mwvisa1

0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22827915
I answered above, but yours is correct which is why I was giving you kudos!
0
 
LVL 1

Expert Comment

by:Nullable
ID: 22827932
sorry i use bad VERB ( SEE )
i must use ( seen )(past)

my english is bad :(
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now