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

dzumwaltAsked:
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.

Juan_BarreraCommented:
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")
                    'Or:
                    c.BackColor = Drawing.Color.Green
                End If
            Next
        End If

Open in new window

0

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?
0
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?
0
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
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.