0

Sorted. I've added the following in Page_Load. So simple

For Each thingy As RepeaterItem In uxMaterialNeedsRepeater.Items
    Dim uxRepeaterItemPanel As Panel = CType(thingy.FindControl("uxRepeaterItemPanel"), Panel)
    uxRepeaterItemPanel.BackColor = Nothing
Next

I Have a repeater

<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>

and when a user clicks the LinkButton generating an ItemCommand I highlight the 'row' the user has selected

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

but if they select another row then I have two rows highlighted (highlit?) and I want to un-highlight the original row. So my thinking is to auto un-highlight all rows first.

How do I do this?

I've tried a few things including setting it at the ItemCreated event but that doesn't work either.

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
Westicle
  • 87
  • 1
  • 13
  • 1
    Check this out: http://stackoverflow.com/questions/6281559/asp-net-repeater-loop-through-items-in-the-item-template – Alexander Jul 02 '13 at 07:59
  • Well that gets me one step closer. What I need to do is this: `For Each thingy As RepeaterItem In uxMaterialNeedsRepeater.Items Dim uxRepeaterItemPanel As Panel = CType(e.Item.FindControl("uxRepeaterItemPanel"), Panel) uxRepeaterItemPanel.BackColor = Nothing Next` But I can't work out what event I can put that it. – Westicle Jul 02 '13 at 08:23
  • Is this question resolved? If it is, you can post your solution as an answer so that other people can benefit from your experience. – Shai Cohen Jul 02 '13 at 18:14
  • Cheers @ShaiCohen I didn't realise I could do that. – Westicle Jul 03 '13 at 06:59

1 Answers1

0

This was actually a very simple fix.

I looped through the repeater items on page load and reset the back colour of every panel control first.

For Each thingy As RepeaterItem In uxMaterialNeedsRepeater.Items
    Dim uxRepeaterItemPanel As Panel = CType(thingy.FindControl("uxRepeaterItemPanel"), Panel)
    uxRepeaterItemPanel.BackColor = Nothing
Next
Westicle
  • 87
  • 1
  • 13