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 964439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:49:37+00:00 2026-05-16T01:49:37+00:00

The following FindControl method fails to find the imgAd control. Any idea why? Could

  • 0

The following “FindControl” method fails to find the imgAd control. Any idea why? Could it be the Table that contains it? The intent of the table is to line things up in columns across rows.

<asp:Content ID="Content3" ContentPlaceHolderID="phPageContent" runat="Server">
    <asp:Repeater ID="repBanner" runat="server">
        <HeaderTemplate>
            <table>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <asp:Image ID="imgAd" runat="server" AlternateText="Panda Visa" ImageUrl="Images/AffiliateBanners/125%20by%20125.jpg" />
                </td>
                <td>
                    <asp:TextBox ID="txtHtml" runat="server" Columns="80" ReadOnly="True" Rows="7" TextMode="MultiLine"></asp:TextBox>
                </td>
                <td>
                     <asp:Button runat="server" Text="Copy HTML to Clipboard" OnClientClick="ClipBoard('txtHtml')" />
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>


Protected Sub repBanner_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repBanner.ItemDataBound

    Dim CurrentAd As Ad = CType(e.Item.DataItem, Ad)
    Dim RepeaterItem As RepeaterItem = e.Item

    Dim imgAd As Image = CType(RepeaterItem.FindControl("imgAd"), Image)
    imgAd.ImageUrl = "Images/" & "125 by 125.jpg" '<<<Error occurs here

End Sub

Object reference not set to an instance of an object.

Here’s some debug info that I thought may help:

? RepeaterItem.Controls.Count
1
? RepeaterItem.Controls(0).Controls.Count
0
? typename(RepeaterItem.Controls(0))
"LiteralControl"
  • 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-16T01:49:38+00:00Added an answer on May 16, 2026 at 1:49 am

    You need to check e.Item.ItemType to make sure that you’re dealing with an item, not a header or footer. Something like this:

    Protected Sub repBanner_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repBanner.ItemDataBound
        If (e.Item.ItemType <> ListItemType.Item AndAlso e.Item.ItemType <> ListItemType.AlternatingItem) Then
            Return
        End If
    
        Dim CurrentAd As Ad = CType(e.Item.DataItem, Ad)
        Dim RepeaterItem As RepeaterItem = e.Item
    
        Dim imgAd As Image = CType(RepeaterItem.FindControl("imgAd"), Image)
        imgAd.ImageUrl = "Images/" & "125 by 125.jpg" '<<<Error occurs here
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a Generic FindControl method and I get the following
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
I have a repeater control: <table style=width: 100%> <asp:Repeater runat=server ID=rptOptions OnItemDataBound=rptOptions_ItemDataBound> <HeaderTemplate> <tr>
The following code ((CheckBox)e.Row.FindControl(exportCb)).CssClass = enabledExport; Creates html <span class=enabledExport><input id=_ctl0_ContentPlaceHolder1_gridviewName__ctl2_exportCb type=checkbox name=_ctl0:ContentPlaceHolder1:gridviewName:_ctl2:exportCb /></span>
Im new to C# and in VB i could do the following: Protected Sub
I'm a beginner at ASP.net, and want to create a class file that contains
I have the following function that updates the UpdatePanel content by adding/loading an ascx
I Have the following code which fires OnCreatedUser and doesn't throw any errors. Profile.Title
Assuming I have the following repeater. <asp:Repeater ID=MyRepeater runat=server onitemdatabound=MyRepeater_ItemDataBound> <FooterTemplate> </table> <asp:Button ID=btnPrevious
I am trying to create a custom datasource control. I have been following 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.