Link to home
Start Free TrialLog in
Avatar of dzumwalt
dzumwalt

asked on

Setting back color on repeater row. I can't see a HtmlTableCell control.

I have seen the solution in Question # 21206598 where the ItemDataBound event is scanning for a HtmlTableCell object as follows:

    Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound

        If e.Item.ItemType = ListItemType.Item Then
            For i As Integer = 0 To e.Item.Controls.Count - 1
                If e.Item.Controls(i).GetType() Is GetType(HtmlTableCell) Then
                    Dim c As HtmlTableCell = CType(e.Item.Controls(i), HtmlTableCell)
                    c.BgColor = "Green"
                End If
            Next
        End If

    End Sub

My problem is that it NEVER finds an HTMLTableCell. My ASP code is as follows:

What am I missing?
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="sqldsAuctionCatalog">
    <HeaderTemplate>
        <table border="1" cellpadding="0" cellspacing="0" style="width:98%">
            <tr style="width:10%; background-color:Black; color:white">
                <td>Image</td>
                <td style="width:10%">Lot Number</td>
                <td style="width:60%">Description</td>
                <td style="width: 20%">Special Operations</td>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
            <tr>
                <td style="width: 10%">
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/ItemDetails.aspx?ItemID=" & DataBinder.Eval(Container.DataItem,"LiveAuctionInventoryItemUniqueID") %> '>
                        <asp:Image ID="Photo" runat="server" ImageUrl='<%# "~/PhotoRetrievers/GetItemThumbnail.aspx?ItemID=" & DataBinder.Eval(Container.DataItem,"LiveAuctionInventoryItemUniqueID") & "&Sequence=" & DataBinder.Eval(Container.DataItem,"SequenceNumber") %> '/>
                    </asp:HyperLink>
                </td>
                <td style="width:10%; font-size:x-large" ><%#DataBinder.Eval(Container.DataItem,"LotNumber") & DataBinder.Eval(Container.DataItem,"LotSubLetter") %></td>
                <td style="width:60%; vertical-align: text-top; text-align:left" ><%#DataBinder.Eval(Container.DataItem,"ShortDescription") & " - " & DataBinder.Eval(Container.DataItem,"LongDescription") %></td>
                <td style="width: 20%">
                    <asp:Button ID="btnEnterAbsenteeBid" runat="server" Style="z-index: 100; left: 0px; position: static; top: 0px; width:100%" Text='Enter Absentee Bid' CommandName="ABSENTEEBID" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"LiveAuctionInventoryItemUniqueID") %>' ></asp:Button>
                    <asp:Button ID="btnEnterConditionReportRequest" runat="server" Style="z-index: 100; left: 0px; position: static; top: 0px; width:100%" Text='Request Condition Report' CommandName="CONDRPTREQ" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"LiveAuctionInventoryItemUniqueID") %>' ></asp:Button>
                </td>
            </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Juan_Barrera
Juan_Barrera
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dzumwalt
dzumwalt

ASKER

Sorry for not getting back to this for so long!

I tried that code but apparently the control isn't DataControlFieldCell because the following line:

If c IsNot Nothing Then

never returns true.

Any idea what that type is? Can you see how to find out?
it appears that it is a System.Web.UI.DataBoundLiteralControl. which of course doesn't have a background  color property nor does it appear to have a style property to which I can add a property.

Again ... any ideas?