views:

241

answers:

1

Hi All,

I have a Datalist. Following is the structure of the ItemTemplate:

<ItemTemplate>                                        
  <div id="driversGrid" runat="server" style="width:3500px;" >
    <table cellpadding="0" cellspacing="0" border="0" width="3500px"> 
      <tr>
        <td id="Td1" runat="server" style="visibility:hidden;">
          <asp:Label ID="lblID" runat="server" BackColor="White" Font-Bold="true" Text='<%# Eval("ID") %>'  /><br />
        </td>
        <td id="title" style="width:90px;text-align:center;">
          <asp:Label ID="lblTitle" runat="server" BackColor="White" Font-Bold="true" Text='<%# Eval("Name") %>'  /><br />
        </td>
        <td id="am0900" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am0915" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am0930" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am0945" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am1000" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am1015" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am1030" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am1045" runat="server" style="width:90px;">&nbsp;</td>
        <td id="am1100" runat="server" style="width:90px;">&nbsp;</td>
      </tr>
    </table>
  </div>          
</ItemTemplate>

Now, At the itemdatabound event, i fetch multiple time(data) from the database in form 10:25 AM. I manipulate each data and convert it to "am1030" (similar to one of the td ID in itemTemplate). Now i want to check each td in ItemTemplate and compare the "lblID"(i.e. the staff ID) to the ID in my variable and then compare the tdID to the manipulated data. If they match change the background color of the td.

In short, i want to check that if the lblID is 3 then get the td with ID am1030 and change the back ground color.

Need to be done in C#.net.

This is very urgent please help.

Khushi

A: 

Use a foreach loop to iterate through the e.Item.Controls collection, like this -

foreach (Control c in e.Item.Controls) { //if c is HtmlCell, then check the ID and change the color. }

Kirtan