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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:17:59+00:00 2026-05-14T04:17:59+00:00

Sample code <asp:Repeater> <ItemTemplate> <asp:ListView DataSource=<%# Container.DataItem.Items %> … /> <asp:DataPager …. /> </ItemTemplate>

  • 0

Sample code

<asp:Repeater>

  <ItemTemplate>

    <asp:ListView DataSource=<%# Container.DataItem.Items %> ... />

    <asp:DataPager .... />

  </ItemTemplate>

</asp:Repeater>

This does not work.

The repeater data source is not a datasource control

It is set like so

repeater.DataSource = datasource
repeater.DataBind()

  • 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-14T04:18:00+00:00Added an answer on May 14, 2026 at 4:18 am

    It is possible, and I’ve done it many times before.

    You may have to wire up the events yourself, and you do have to use FindControl() in the repeaters item databound event to grab the specific ListView in order to set the Data Source, and also to call DataBind on it.

    You can use the data binding shortcut <%# ... %> within the nested Repeater / DataList, but not to set the DataSource as you have done.


    Paste the following into a blank new project. Compiles and runs.

    (Big disclaimer – the html is just for demonstration and is pretty poor.)

    Web Form Code.

    <asp:ListView ID="dlOuter" runat="server" 
    onitemdatabound="dlOuter_ItemDataBound">
    <LayoutTemplate>
    <div id="personGroupList">
            <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
        </div>
    </LayoutTemplate>    
    <ItemTemplate>
        <div class="groupHeading"><%# Eval("Key") %></div>
        <asp:ListView ID="dlInner" runat="server" 
          ItemPlaceholderID="innerItemPlaceHolder"
          onitemdatabound="dlInner_ItemDataBound"
        >
        <LayoutTemplate>
            <asp:PlaceHolder ID="innerItemPlaceHolder" runat="server" />
        </LayoutTemplate>
        <ItemTemplate>
            <div class="person">
            Name: <%# Eval("Name") %>
            Age: <%# Eval("Age") %>
            </div>
        </ItemTemplate>
        </asp:ListView>
    </ItemTemplate>
    </asp:ListView>
    

    Now in the code behind

    protected void Page_Load(object sender, EventArgs e)
    {
      // takes a list of Person and group's by Person.City
      // really this is just an outer grouping that's in use.
      var query = from p in Person.GetPersons() select p;
      dlOuter.DataSource = query.ToLookup(o => o.City);
      dlOuter.DataBind();
    }
    
    // The outer List View is the groups.
    // we bind the inner view to the list if Person in the group.
    protected void dlOuter_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
      if (e.Item.ItemType == ListViewItemType.DataItem)
      {
        ListViewDataItem di = (ListViewDataItem)e.Item;
        ListView inner = (ListView)e.Item.FindControl("dlInner");
    
        IGrouping<string, Person> lookup = (IGrouping<string, Person>)di.DataItem;
        inner.DataSource = lookup.AsEnumerable();
        inner.DataBind();
      }
    }
    protected void dlInner_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        // included so you can see how it's wired up. Unused in this sample.
    }
    

    Person class is just for demonstration.

    public class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string City { get; set; }
    
        public static List<Person> GetPersons()
        {
            List<Person> persons = new List<Person>
            {
                new Person { Name="Bob", Age=30, City="Chicago" },
                new Person { Name="Mary", Age=20, City="NYC" },
                new Person { Name="Marty", Age=12, City="LA" },
                new Person { Name="Fred", Age=33, City="NYC" },
                new Person { Name="Susan", Age=22, City="Chicago" }
            };
            return persons;
        }
    }
    

    Note that in this example I’m grouping using ToLookup to create a grouping from a list. In the real code this is derived from, it’s showing a page of data ordered by what happens on a particular day. E.g. the records are sorted by thing.SomeDate and the grouping is query.ToLookup( o => o.SomeDate.ToLongDateString() );

    It’s important to note that the ToLookup and use of IGrouping<T,X> is irrelevant except I need to get grouped data in there somehow for the purposes of example. You could just as easily have the canonical example of Order and OrderDetail where the outer ListView is a List<Order> and the inner ListView is the Order.OrderDetails

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.