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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:04:11+00:00 2026-05-25T06:04:11+00:00

I cant seem to figure out whats wrong with this set of code. I

  • 0

I cant seem to figure out whats wrong with this set of code. I have my front end:

<asp:Repeater ID="ArchiveYearRepeater" runat="server" OnItemDataBound="ArchiveYearRepeater_ItemDataBound">

    <ItemTemplate>
        <div class="ArchiveYear">
            <h3><% DataBinder.Eval(Container.DataItem); %></h3>
            <ul>
                <asp:Repeater ID="ArchivePostRepeater" runat="server">
                    <ItemTemplate>
                        <li><a href="<% DataBinder.Eval(Container.DataItem, "URL"); %>"><% DataBinder.Eval(Container.DataItem, "Title"); %></a></li>
                    </ItemTemplate>
                </asp:Repeater>
            </ul>
        </div>
    </ItemTemplate>

</asp:Repeater>

Then I have my code behind:

protected void Page_Load(object sender, EventArgs e)
        {


            ArchiveYearRepeater.DataSource = GetYears();
            ArchiveYearRepeater.DataBind();

        }
        protected List<ArchiveItem> GetArchiveItems()
        {
            List<ArchiveItem> ArchiveItems = new List<ArchiveItem>();
            List<BlogPost> posts = BlogPostManager.GetBlogPosts(0, BlogPostManager.BlogSection());

            foreach (BlogPost post in posts)
            {
                ArchiveItem archiveRecord = new ArchiveItem();
                archiveRecord.Title = post.Title;
                archiveRecord.Link = post.URL;
                archiveRecord.Date = post.Date;
                archiveRecord.Year = post.Date.ToString("yyyy");
                ArchiveItems.Add(archiveRecord);
            }

            return ArchiveItems;
        }
        protected List<string> GetYears()
        {
            List<string> Years = new List<string>();
            List<ArchiveItem> ArchiveItems = new List<ArchiveItem>();
            ArchiveItems = GetArchiveItems();
            foreach (ArchiveItem item in ArchiveItems)
            {
                if(!Years.Contains(item.Year)){
                    Years.Add(item.Year);
                }
            }

            return Years;
        }
        private void ArchiveYearRepeater_ItemDataBound(object sender,
    System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;
            if ((item.ItemType == ListItemType.Item) ||
                (item.ItemType == ListItemType.AlternatingItem))
            {
                Repeater ArchivePostRepeater = new Repeater();
                ArchivePostRepeater = (Repeater)item.FindControl("ArchivePostRepeater");

                ArchivePostRepeater.DataSource = GetArchiveItems();
                ArchivePostRepeater.DataBind();
            }
        }

I am trying to make the outer most repeater repeat the years that are found in the main data set of “BlogPost”. Then the inner repeater I am trying to write out each post that falls into that year. I am using sharepoint so this thing is throwing errors that I cant quite seem to debug.

  • 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-25T06:04:11+00:00Added an answer on May 25, 2026 at 6:04 am

    Your main problem is that you do not have proper databinding syntax in your aspx code. It should be:

    <%# DataBinder.Eval(Container.DataItem, "URL") %>
    

    Also, in your first databinding call, you can do the following because it’s a list of strings:

    <%# Container.DataItem %>
    

    Beyond that, there are a few other issues with your logic in the ItemDatabound event. You are calling the same GetArchiveItems for every year. Which means that you will get your entire list of ArchiveItems for every year. You should be retrieving the currently bound year and passing that to your GetArchiveItems function so that you can retrieve only those that are related to that year.

    Also, you do not need to initialize your ArchivePostRepeater variable to a new Repeater() object, because you are setting it to another one in the code immediately after that. You can just set it to null initially.

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

Sidebar

Related Questions

Hey everyone - I cant seem to figure out what i am doing wrong
I have been trying to figure out whats wrong for quite long time yet
What's wrong with this? I can't seem to figure out how to change it.
I can't seem to figure out what's wrong with my function.... I need to
I can't seem to figure out what I am doing wrong here. I publish
I can't seem to figure out a good way to do this, but it
I can't seem to figure out how to set the default database in Sql
I have another script that I can't figure out what is wrong with it.
Alright, I can't seem to figure out what is going on, so I have
I've seen the other posts, but can't seem to figure out why this isn't

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.