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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:23:10+00:00 2026-05-26T00:23:10+00:00

TL;DR The Control inside my Repeater requires special instantiation before it can be useful.

  • 0

TL;DR

The Control inside my Repeater requires special instantiation before it can be useful. How do I perform this special instantiation for each control as they are constructed by the repeater?

The Setup

I have three classes:

ComplexData.

Contains many public members of varying types, such as:

  • int favorite_integer
  • Food what_you_had_for_breakfast_this_morning
  • string capital_of_alaska
  • PhaseOfMoon when_magic_runes_will_reveal_themselves_on_the_mysterious_artifact

etc, etc, etc

ComplexDataDisplay

A control used to render an instance of ComplexData in an aesthetically pleasing way. Exposes a single public member, ComplexMember DataToDisplay. When the user sets DataToDisplay, the labels within the control will populate themselves with the appropriate data.

MultiComplexDataDisplay

A control that uses a Repeater to display multiple ComplexDataDisplays in a row. It contains a private List<ComplexData> datasToDisplay, which is the data source for the repeater. It provides two public methods, addComplexData(ComplexData) and emptyAllData(), which let the user manipulate datasToDisplay.

The Problem

During the data bind process, I don’t know how to set each ComplexDataDisplay’s DataToDisplay member.

It appears that controls within repeaters are normally populated from the front end, for example

<asp:Repeater runat="server" id="linkRepeater">
    <a href="<%# getUrl(Container.DataItem) %>"> <%# getDescription(Container.DataItem) %> </a>
</asp:Repeater>

As I understand it, during data bind, the repeater instantiates each anchor element, using whatever the data source is to set the href and description.

My attempt to replicate this behavior only led to a blank page:

<asp:Repeater runat="server" id="displayRepeater">
    <ComplexDataDisplay id="dataDisplay" DataToDisplay="<%# Container.DataItem %>" runat="server"
</asp:Repeater>

The only other thing I can think to try is to modify ComplexDataDisplay so it has a public member for each member of ComplexData. Then within the repeater I can do:

<asp:Repeater runat="server" id="displayRepeater">
    <ComplexDataDisplay id="dataDisplay" runat="server"
        favorite_integer="<%# get_favorite_integer(Container.DataItem) %>"
        what_you_had_for_breakfast_this_morning="<# get_what_you_had_for_breakfast_this_morning(Container.DataItem) %>"
        <%--etc etc etc--%>
    />
</asp:Repeater>

This seems highly undesirable because for every member of ComplexData, I’ll have to write a corresponding public member in ComplexDataDisplay, and a get_whatever(DataItem) method in MultiComplexDataDisplay. On top of that, I don’t even know if it will work, because half of ComplexData’s members are complex data types, which may or may not be settable in this way.

What I’m looking for in an answer

One of the following:

  • A direct answer to the question posed in the TLDR section – a way to perform special instantiation for each control in the repeater during databind, or a way to iterate through them shortly after the fact.
  • A recommendation on how to best restructure the code, such so that special instantiation is no longer necessary to display my many Complex Datas. I am willing to add/update/delete any class besides ComplexData, as I am obligated to maintain its interface as-is.
  • best practices/references/documentation related to my problem, which will guide me in finding a solution myself.
  • 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-26T00:23:11+00:00Added an answer on May 26, 2026 at 12:23 am

    You can bind you child controls inside of ItemDataBound, I couldn’t follow which objects get bound when so replace where needed:

    <asp:Repeater runat="server" id="displayRepeater" OnItemDataBound="displayRepeater_ItemDataBound">
        <uc1:ComplexDataDisplay id="dataDisplay" runat="server" />
    </asp:Repeater>
    
    
     protected void displayRepeater_ItemDataBound(Object Sender, RepeaterItemEventArgs e) 
     {
          // Execute the following logic for Items and Alternating Items.
          if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 
          {
             //get object bound to row
             ComplexData c = (ComplexData)e.Item.DataItem;
             //find the child control to bind
             ComplexDataDisplay cds = (ComplexDataDisplay)e.Item.FindControl("dataDisplay");
             //set properties or any other complex things you need to do
             cds.DataToDisplay = c.ComplexMember;
             cds.DataBind(); // if this control has repeaters, it's ItemDataBound will fire, repeat this process untill all your controls are bound properly
          }
       }    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a hidden control inside a repeater. How can I access this from
I want a Repeater control inside a Gridview row. So how can I assign
I have a user control in which I have Repeater control and inside this
I am trying to access a control inside a Repeater. The control is inside
I have one control named thumbviewer inside repeater. I want to set its imageurl
I have a user control nested in a repeater. Inside my user control I
I have an image control inside a repeater. I would like to exclude/ignore a
I have a user control with linkbuttons (used for paging) and a repeater inside
In a user control, I've got a Repeater inside of an UpdatePanel (which id
I've a asp.net linkbutton inside asp.net repeater control which renders multiple link buttons. I

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.