PlaceHolder inside ContentPlaceholder

Posted on 2008-11-04
Last Modified: 2013-12-17
Why is it not possible to access PlaceHolder control from cs file, which is placed in ContentPlaceHolder aspx page in the Content section?
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentCategories" runat="Server">

<ASP:DataList id="CatDataList" RepeatColumns="1" runat="server">


        <table cellpadding="10" style="font: 10pt verdana">



            <td valign="top">

              <b>Category: </b><%# DataBinder.Eval(Container.DataItem, "CategoryName") %> <br /> <br />

              <asp:PlaceHolder ID="phGridProject" runat="server"> </asp:PlaceHolder>                       









Open in new window

Question by:VonGunten
    LVL 4

    Expert Comment

    It's because you have it nested in a DataList ItemTemplate.

    Author Comment

    Ok, but how to reach it?

    I tried with:
    PlaceHolder ph1 = ((PlaceHolder)CatDataList.FindControl("phGridProjects"));

    but when I try to add a control to ph1 there is an exception thrown that the reference is not set to an instance of an object.

    How to reach this PlaceHolder.

    Author Comment

    One more thing. I try to reach it in inside of OnItemDataBound method.

    Accepted Solution

    Ok. I got it. It has to be:

     PlaceHolder ph1 = ((PlaceHolder)e.Item.FindControl("abc"));

    Thanks anyway

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    734 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

    24 Experts available now in Live!

    Get 1:1 Help Now