Reference repeater table cell

Greetings!

I've been trying, without success, to figure out how to reference a repeaters' table cell.

Basically, I've the repeater included below.  As the date values get entered, the background color needs to be changed depending upon elapsed time.  Basic colors are red, yellow and green.  Changing the label background and foreground colors are the problem.  The problem is changing the container table cell background color to match the respective cells' label background color.  This is the requirement that I've been presented and I've been, without success, trying to figure out.

Looks like the label parent is the repeater.  Is there any way to get the cell containing the label?

Thanks!
Allidap



<asp:Repeater ID="RepeaterData" runat="server">
<HeaderTemplate>
<table id="RepeaterTable">
</HeaderTemplate>
<ItemTemplate>
<tr>
      <td><asp:Label ID="LabelDate102" runat="server" Text='<%#Container.DataItem("Date2")%>' Visible="false"></asp:Label></td>
                     <td><asp:Label ID="LabelDate103" runat="server" Text='<%#Container.DataItem("Date3")%>' Visible="false"></asp:Label></td>
                     <td><asp:Label ID="LabelDate104" runat="server" Text='<%#Container.DataItem("Date4")%>' Visible="false"></asp:Label></td>
                     <td><asp:Label ID="LabelDate105" runat="server" Text='<%#Container.DataItem("Date5")%>' Visible="false"></asp:Label></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
allidapAsked:
Who is Participating?
 
Joel CoehoornConnect With a Mentor Director of Information TechnologyCommented:
A repeater just generates html, and nothing more.  A grid will also provide hooks for your codebehind, so you can do something like this to directly access a specific cell:


GridView1.Rows(0).Cells(0).Text = "some text"
or
GridView1.Columns(0).ItemStyle.BorderColor = Drawing.Color.Black
0
 
Joel CoehoornDirector of Information TechnologyCommented:
Repeaters will output any html you specify.  This doesn't have to be a table.  This means that as far as the repeater is concerned, there's no such thing as a cell.  If you really want programmatic access to cells you're probably better off using one of the grid controls (there are at least three different grid controls included with .Net).
0
 
allidapAuthor Commented:
In this case, the repeater generates a table in the HTML...

                                            <table id="RepeaterTable">
                                            <tr>
                                                <td>
                                                </td>
                                                <td><span id="RepeaterData_ctl01_LabelDefinition"></span></td>
                                                <td>
                                                </td>
                                                <td>
                                                </td>
                                             ...

How is a data grid control different in accessing the respective table cell?



0
 
allidapAuthor Commented:
Found a solution that allows accessing a repeater table cell.  It utilizes htmltablecell; e.g.,

     dim td as htmltablecell

     td = ctype(ritem.findcontrol("..."), htmltablecell)
     
with this, you have complete control to all of the cell attributes.

0
All Courses

From novice to tech pro — start learning today.