パネル内にリピーターがあります。
このリピーターの中にもうひとつパネルがありますpanel.visibility = false
。
コード ビハインドでは、パネルをオンにしてOnItemDataBound
、visible=false を設定してみます。しかし、それは返すだけObject reference not set to an instance of an object.
です。パネルが見つからないからだと思います。
これが私のコードです:
<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>
そして、ここに私のコードビハインドがあります:
protected void repComments_OnDataBound(Object sender, RepeaterItemEventArgs e)
{
Panel panel = (Panel)Repeater1.FindControl("commentAdminPanel");
panel.Visible = false;
}
私は何を間違っていますか?