抱歉,如果这篇文章看起来很啰嗦。
我有一个带有嵌套中继器的父中继器。
我的问题是我正在尝试使用“下一个”和“上一个”按钮重新绑定我的转发器(rptTabContent),因此也绑定了内部转发器,但是当我尝试在 ItemCommand 事件期间操纵这些链接的状态时,它们被覆盖绑定。
因此,如果在单击“下一个”或“上一个”链接后没有数据,我将无法禁用或启用这些按钮,这是我正在尝试做的。
嵌套的中继器在 7 列中显示了一周的数据。下一个按钮用于显示下一周的数据和前一周的数据。最初,前一个按钮是不活动的。
父中继器再次绑定,因为最初它循环出 4 个 div,每个 div 包含一个数据表。如果在一个中继器上按下一个下一步按钮,则所有表格都必须显示其接下来 7 天的数据。
每个中继器具有完全相同数量的项目。
最初在页面加载时,所有数据都正确绑定。
我知道我的收藏中第一项和最后一项的日期,因此我能够计算我需要绑定到我的父中继器的对象的日期范围。
HTML 如下
<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>
我的 ItemCommand 事件在这里:
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
如何在这些条件下管理我的“下一个”和“上一个”链接。
非常感谢