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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:17:56+00:00 2026-05-11T12:17:56+00:00

Sorry if this post appears to be long winded. I have a parent repeater

  • 0

Sorry if this post appears to be long winded.

I have a parent repeater with nested repeaters.

My problem is I am trying to use ‘Next’ and ‘Previous’ buttons to rebind my repeater (rptTabContent) and thus the inner repeaters also, but when I try to manipulate the state of these links during the ItemCommand event they are overwritten by the bind.

So I cannot disable or enable the buttons if there is to be no data after a consquent click of either ‘Next’ or ‘Previous’ links which is what I am trying to do.

The nested repeaters show a weeks worth of data in 7 columns. The next button is meant to show the next weeks data and previous the previous weeks data. Initially the previous button is inactive.

The parent repeater is bound again because initially it loops out 4 divs each containing a table of data. If one next button is hit on one repeater all tables must show their next 7 days of data.

Each repeater has the exact same number of items.

Initially on page load all of the data bind correctly.

I know the date of the very first item and last item in my collection so I am able to calculate the date range of the objects I need to bind to my parent repeater.

The HTML is below

        <asp:Repeater ID='rptTabContent' runat='server' OnItemCommand='rptTabContent_ItemCommand'>         <ItemTemplate>             <div id='<%# Eval('SlotTypeUrl') %>' class='delivery-timetable-container'>                 <table cellpadding='0' cellspacing='0' border='0'>                     <asp:Repeater ID='rptDeliverySlots' runat='server'>                         <ItemTemplate>                             <tr class='time-slots'>                                 <th><asp:Label id='lblRowTime' runat='server'></asp:Label></th>                                 <asp:Repeater ID='rptDeliverySlot' runat='server'>                                     <ItemTemplate>                                         <td id='tdDay' runat='server'>                                             <cc1:RepeaterRadioButton id='rptrdoDeliverySlot' groupname='del-times' runat='server' />                                         </td>                                                </ItemTemplate>                                  </asp:Repeater>                                                         </tr>                         </ItemTemplate>                     </asp:Repeater>                     <tr>                         <td colspan='8'>&nbsp;</td>                     </tr>                     <tr>                         <td colspan='4'>                                             <div class='eco-rollover'>                                     <div>                                         <img src='icon.gif' />                                     </div>                                 </div>                         </td>                         <td colspan='4'>                             <asp:LinkButton id='lnkPreviousWeek' enabled='false'  runat='server' commandargument='Previous' cssclass='inactive'>&lt; Previous week</asp:LinkButton>|                             <asp:LinkButton id='lnkNextWeek' runat='server' commandargument='Next' cssclass='active' >Next week &gt;</asp:LinkButton>                         </td>                     </tr>                 </table>             </div>         </ItemTemplate>     </asp:Repeater> 

My ItemCommand event is here:

Protected Sub rptTabContent_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs)      If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem)         Dim filteredProposedDeliveries  As New List(Of ProposedDeliverySlotDTO)         Dim firstDate, lastDate As Date         Dim startDate, endDate  As Date          If (Session('FirstDeliveryDate') IsNot Nothing) AndAlso (Session('LastDeliveryDate') IsNot Nothing) Then              firstDate = CType(Session('FirstDeliveryDate'), Date)             lastDate  = CType(Session('LastDeliveryDate'),  Date)               Select Case e.CommandArgument.ToString()                 Case 'Next'                         'Get new startDate using firstDate and store to use next time                     'disable next button if startDate > lastDate                 Case 'Previous'                     'Get new startDate from current displayed date and overright stored startdate                     'disable previous button if startDate < firstDate             End Select              endDate = startDate.AddDays(7)               End If          'filteredProposedDeliveries = Get object between startDate and EndDate          Dim slots As List(Of SlotType)  = PrepareSlotsForBinding(filteredProposedDeliveries)                      Dim rptTabContent As Repeater = CType(e.Item.BindingContainer, Repeater)         rptTabContent.DataSource = slots         rptTabContent.DataBind()     End If End Sub 

How can I manage my ‘Next’ and ‘Previous’ links under these conditons.

Many thanks

  • 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. 2026-05-11T12:17:56+00:00Added an answer on May 11, 2026 at 12:17 pm

    Are you sure you need next/previous buttons four times?

    Anyway, do your button management on rptTabContent_ItemDataBound. On ItemCommand, you get new starting point, get data and do data bind. On ItemDataBound, you get the Next button and the Previous button and enable or disable them based on what current date is. Both buttons should be disabled in the markup as a default state (for when there is no data).

    Here is a working sample that simulates a data source of four items.

    Page

    <asp:Repeater ID='Repeater1' runat='server' onitemcommand='Repeater1_ItemCommand' onitemdatabound='Repeater1_ItemDataBound'>     <ItemTemplate>         <div>             Label: <asp:Label ID='itemLabel' runat='server'></asp:Label><br />             <asp:LinkButton id='lnkPreviousWeek' Enabled='false' runat='server' commandargument='Previous' cssclass='inactive'>&lt; Previous week</asp:LinkButton>&nbsp;|&nbsp;             <asp:LinkButton id='lnkNextWeek' Enabled='false' runat='server' commandargument='Next' cssclass='active' >Next week &gt;</asp:LinkButton>             <hr />         </div>     </ItemTemplate> </asp:Repeater> 

    Code

    private int current = 1;  protected void Page_Load(object sender, EventArgs e) {     if (ViewState['current'] == null)         ViewState['current'] = current;     else         current = (int)ViewState['current'];      if (!IsPostBack)     {         Repeater1.DataSource = GetData(current);         Repeater1.DataBind();     } }  private List<int> GetData(int start) {     //pseudo data; simulates a page of 2 records     List<int> ds = new List<int>();     ds.Add(start);     ds.Add(start + 1);      return ds; }  protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) {     if ((string)e.CommandArgument == 'Next')         current++;     else if ((string)e.CommandArgument == 'Previous')         current--;      ViewState['current'] = current;      Repeater1.DataSource = GetData(current);     Repeater1.DataBind(); }  protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) {     LinkButton prev = (LinkButton)e.Item.FindControl('lnkPreviousWeek');     LinkButton next = (LinkButton)e.Item.FindControl('lnkNextWeek');      //here 1 and 3 are artificial boundaries for data for the sake of example     if (current > 1)         prev.Enabled = true;     if (current < 3)         next.Enabled = true;      Label label = (Label)e.Item.FindControl('itemLabel');     label.Text = e.Item.DataItem.ToString(); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There's no problem using mocks for this, since you are… May 11, 2026 at 1:36 pm
  • added an answer The advice of going the QPalette route worked out. Here… May 11, 2026 at 1:36 pm
  • added an answer This should do it: sed 's/^\([\'']\)\(.*\)\1\$/\2/g' in.txt Where in.txt is:… May 11, 2026 at 1:36 pm

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.