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"> </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">< Previous week</asp:LinkButton>|
<asp:LinkButton id="lnkNextWeek" runat="server" commandargument="Next" cssclass="active" >Next week ></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