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>
It's because you have it nested in a DataList ItemTemplate.
ASKER
Ok, but how to reach it?
I tried with:
PlaceHolder ph1 = ((PlaceHolder)CatDataList. FindContro l("phGridP rojects")) ;
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.
I tried with:
PlaceHolder ph1 = ((PlaceHolder)CatDataList.
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.
ASKER
One more thing. I try to reach it in inside of OnItemDataBound method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.