Link to home
Start Free TrialLog in
Avatar of VonGunten
VonGunten

asked on

PlaceHolder inside ContentPlaceholder

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">
      <ItemTemplate>
        <table cellpadding="10" style="font: 10pt verdana">
          <tr>
            <td/>
            <td valign="top">
              <b>Category: </b><%# DataBinder.Eval(Container.DataItem, "CategoryName") %> <br /> <br />
              <asp:PlaceHolder ID="phGridProject" runat="server"> </asp:PlaceHolder>                       
              
            </td>
          </tr>
        </table>
 
      </ItemTemplate>
 
 </ASP:DataList>
     
</asp:Content>

Open in new window

Avatar of BToson
BToson
Flag of United Kingdom of Great Britain and Northern Ireland image

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

ASKER

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.
One more thing. I try to reach it in inside of OnItemDataBound method.
ASKER CERTIFIED SOLUTION
Avatar of VonGunten
VonGunten

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial