排序。我在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
答案 0 :(得分:0)
这实际上是一个非常简单的解决方法。
我在页面加载时循环遍历转发器项目并首先重置每个面板控件的背景颜色。
For Each thingy As RepeaterItem In uxMaterialNeedsRepeater.Items
Dim uxRepeaterItemPanel As Panel = CType(thingy.FindControl("uxRepeaterItemPanel"), Panel)
uxRepeaterItemPanel.BackColor = Nothing
Next