Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:17:33+00:00 2026-05-15T23:17:33+00:00

I have a repeater inside a panel. Inside this repeater I have another panel.Upon

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:17:34+00:00Added an answer on May 15, 2026 at 11:17 pm

    One issue is that you are calling the repeater directly, instead of the bound item template – e.Item.FindControl instead of Repeater1.FindControl.

    The other issue is that the ItemDataBound event will also fire for header and footer, and you are not checking the type of list item (ListItemType enum) you are on in the repeater.

    Since you don’t have a header item (which would be the first item to call the handler), there is no panel control and the cast fails.

    You only need the Item and AlternatingItem item types:

    protected void repComments_OnDataBound(Object sender, RepeaterItemEventArgs e)
    {
        if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )
        {
            Panel panel = (Panel)e.Item.FindControl("commentAdminPanel");
            panel.Visible = false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one control named thumbviewer inside repeater. I want to set its imageurl
I have this div inside a repeater, where i set the class, onmouseover and
I have inside repeater when i tried to find above placeholder in code behind
Inside my aspx file, I have the following html code inside an repeater: <div
Here's the scenario: I have a repeater inside an UpdatePanel called updPanel. Inside this
I have a RadioButtonList inside a Repeater. I have AutoPostback set to true and
I have a Linkbutton inside a repeater and I want to delete the Item
I have a repeater and inside it i have a checkbox. Now i want
I have a Repeater and inside it a GridView . Now I want to
I have a user control in which I have Repeater control and inside this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.