排序。我在 Page_Load 中添加了以下内容。很简单
For Each thingy As RepeaterItem In uxMaterialNeedsRepeater.Items
Dim uxRepeaterItemPanel As Panel = CType(thingy.FindControl("uxRepeaterItemPanel"), Panel)
uxRepeaterItemPanel.BackColor = Nothing
Next
我有中继器
<asp:Repeater runat="server" ID="uxMaterialNeedsRepeater">
<ItemTemplate>
<p>
<asp:Panel runat="server" ID="uxRepeaterItemPanel">
<asp:LinkButton runat="server" ID="uxMaterialNeedLinkButton" CssClass="Label" CommandName="Select" CommandArgument='<%#Eval("ID")%>'>Select</asp:LinkButton>
<%#ReturnListOfMaterials(Container.DataItem)%>
</asp:Panel>
</p>
</ItemTemplate>
</asp:Repeater>
当用户单击生成 ItemCommand 的 LinkButton 时,我突出显示用户选择的“行”
Protected Sub uxMaterialNeedsRepeater_ItemCommand(source As Object, e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles uxMaterialNeedsRepeater.ItemCommand
If e.CommandName = "Select" Then
' Highlight the selected row
Dim uxRepeaterItemPanel As Panel = CType(e.Item.FindControl("uxRepeaterItemPanel"), Panel)
uxRepeaterItemPanel.BackColor = Drawing.Color.LightGreen
End If
End Sub
但是如果他们选择另一行,那么我突出显示了两行(突出显示?),我想取消突出显示原始行。所以我的想法是首先自动取消突出显示所有行。
我该怎么做呢?
我已经尝试了一些事情,包括在 ItemCreated 事件中设置它,但这也不起作用。
Protected Sub uxMaterialNeedsRepeater_ItemCreated(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles uxMaterialNeedsRepeater.ItemCreated
' Remove any highlighting from all rows
Dim uxRepeaterItemPanel As Panel = CType(e.Item.FindControl("uxRepeaterItemPanel"), Panel)
uxRepeaterItemPanel.BackColor = Nothing
End Sub