I have a repeater inside a panel.
Inside this repeater I have another panel.Upon certain conditions, I want to set this panel.visibility = false
.
In the code behind, I try locating the panels on OnItemDataBound
and set visible=false. But it only returns Object reference not set to an instance of an object.
. I guesing it's because it can't locate the panel.
Here is my code:
<asp:Panel ID="Panel1" runat="server">
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="repComments_OnDataBound">
<ItemTemplate>
<div>
<asp:Panel runat="server" ID="commentAdminPanel" CssClass="floatRight" >
<img id='deleteComment' class='deleteComment' src='/img/delete1.jpg' />
</asp:Panel>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</asp:Panel>
And here is my code behind:
protected void repComments_OnDataBound(Object sender, RepeaterItemEventArgs e)
{
Panel panel = (Panel)Repeater1.FindControl("commentAdminPanel");
panel.Visible = false;
}
What am I doing wrong?