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

  • Home
  • SEARCH
  • 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 427739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:36:22+00:00 2026-05-12T19:36:22+00:00

I have a asp.net repeater control in a aspx page, with runat=server and an

  • 0

I have a asp.net repeater control in a aspx page, with runat=”server” and an id set, however for some reason i can’t access its ID from code behind (I can access the id of the asp:detaislview control it sits in though). So instead in the page_load method I am doing the following:

Repeater repeater = (Repeater)PromotionSitesDetailsView.FindControl("estateRepeater");
repeater.DataSource = estateList;

However when run, an error comes up saying the repeater is null! All I want to do is set the datasource of this repeater to a List object. Any ideas?

  • 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-12T19:36:23+00:00Added an answer on May 12, 2026 at 7:36 pm

    You said the Repeater sits inside a DataList. The DataList is, itself, a kind of repeater – the controls inside of it don’t exist until the DataList is bound to a datasource, and the controls in the template are created once per item in the source. So if you bind the DataList to a source with 3 items, you will get 3 repeaters.

    So it looks kind of like this:

    Page
        MyDataList
            Item0
                MyRepeater
            Item1
                MyRepeater
            Item2
                MyRepeater
    

    So obviously MyDataList.FindControl("MyRepeater") can’t work – which “MyRepeater” are we talking about? Since multiple controls cannot have the same ID, ASP.NET solves this by making the ID unique to something called a NamingContainer. Since the DataList repeats the same set of controls many times (once per item in the data source), each item in the DataList is a NamingContainer.

    We need to find the NamingContainer we know holds the instance of MyRepeater that we want:

    MyDataList.Items[0].FindControl("MyRepeater");
    

    You can iterate over the items in the DataList after it has been bound (of course, before it has been bound it has no items). You can also operate on a given item in the DataList as that item is being created:

    <asp:DataList OnItemDataBound="MyDataList_HandleItemDataBound" ... />
    
    //this will get called once per item as it is created
    void MyDataList_HandleItemDataBound(object sender, DataListItemEventArgs e)
    {
        //e.Item is the current item being databound
        Repeater myRepeater = e.Item.FindControl("MyRepeater") as Repeater;
        myRepeater.DataSource = //ds
        myRepeater.DataBind();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repeater control on an ASP.NET 2.0 web form. As I understanding
I have an ASP.NET page that uses a repeater nested within another repeater to
I have a ASP.NET page with an asp:button that is not visible. I can't
I have an ASP.NET page with code-behind in VB.NET. On the ASPX page I
I've got an ASP.Net project with C# and have a Repeater Control on an
I have an Asp.Net repeater, which contains a textbox and a checkbox. I need
I know that the asp.net repeater doesnt have a Client side object model, and
I have asp.net form that contains fields. When I access this window, my javascript
So I have ASP.NET running on the server in IIS7. I think I'm going
I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a

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.