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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:05:19+00:00 2026-06-01T07:05:19+00:00

I am trying to get the child repeater’s item count but for some reason

  • 0

I am trying to get the child repeater’s item count but for some reason it keeps coming up as zero. Here is my code: Parent repeater is rptDays. Child repeater is rptEditInfo.

protected void rptDays_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Repeater rptEditInfo = (Repeater)e.Item.FindControl("rptEditInfo");
        ...
        DateTime thisDay = (DateTime)e.Item.DataItem;
        DataSet ds = new DataSet();
        ...
        ds = **bind valid dataset to this variable**
        rptEditInfo.DataSource = MRSTable;
        rptEditInfo.DataBind();
   }

}

protected void rptEditInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Header)
    {
        Repeater rpt2 = (Repeater)((Repeater)e.Item.Parent);
        Repeater rpt1 = (Repeater)((Repeater)sender).Parent.FindControl("rptEditInfo");
        int countTest1 = rpt2.Items.Count //always zero
        int countTest2 = rpt1.Items.Count //always zero
    }
}

What am I doing wrong? The data is valid and populated. Only thing I can think of is that I am not accessing the child repeater properly.

  • 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-06-01T07:05:20+00:00Added an answer on June 1, 2026 at 7:05 am

    You cannot get the item count in the header(e.Item.ItemType == ListItemType.Header). The items will be created in this order:

    1. Header
    2. 1. Item ItemCreated (Count=0 since not databound yet)
    3. 1. Item ItemDataBound (Count=1 since first item created and databound)
    4. 2. Item ItemCreated (Count=1 since not databound yet)
    5. 2. Item ItemDataBound (Count=2 since second item created and databound)
      ….

    So ItemDataBound is not the right stage to get the total count from the Items property. But always a better approach anyway is to use the datasource directly instead instead of counting Items(or Rows in a GridView).

    protected void rptEditInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Header)
        {
            Repeater rpt = (Repeater)sender;
            //note that this depends on your actual datasource, set a breakpoint and debug if you're unsure
            var dataSource = (DataView)rpt.DataSource; 
            int count = dataSource.Count;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get comfortable with jQuery and I have encountered some sample code that
I am trying to get my sltag value but I got some errors in
I am trying to get the children items of a Item.,of which some of
I'm trying to get the first category (level zero, no parents) from a child
I'm trying to get an adapterview to draw its child views properly, but am
I'm trying to find a way to get the total number of child nodes
Trying to get my mind around google protobuf. I found some implementation of protobuf
When I'm trying get method from remote webservice it gives me error. My code
I'm trying to get the text contents of a .div('.child#') child of my event.target('h6.class'),
I'm trying to get a window handle on a child window in my process

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.