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
        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">
        <table border="1" cellpadding="0" cellspacing="0" style="width:98%">
            <tr style="width:10%; background-color:Black; color:white">
                <td style="width:10%">Lot Number</td>
                <td style="width:60%">Description</td>
                <td style="width: 20%">Special Operations</td>
                <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") %> '/>
                <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>

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi there,

If I remember correctly, the control type for a TemplatedField in a Repeater is DataControlFieldCell. Give this a try:

   If e.Item.ItemType = ListItemType.Item Then
            For i As Integer = 0 To e.Item.Controls.Count - 1
                Dim c As DataControlFieldCell = TryCast(e.Item.Controls(i), DataControlFieldCell)
                If c IsNot Nothing Then
                    c.Style.Add("bgcolor", "Green")
                    c.BackColor = Drawing.Color.Green
                End If
        End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dzumwaltAuthor Commented:
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?
dzumwaltAuthor Commented:
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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.