asp.net- Highlight cell in listview -


i have piece of code works fine , highlights label. however, want highlight entire cell not label.

any appreciated!

protected void highlight_itemdatabound(object sender, listviewitemeventargs e) {     if (e.item.itemtype == listviewitemtype.dataitem)     {         label totaltimelabel = (label)e.item.findcontrol("totaltime");         if (totaltimelabel != null)         {             decimal total;             if (decimal.tryparse(totaltimelabel.text, out total) == true)             {                 if (total > (decimal)1.5)                 {                     totaltimelabel.backcolor = system.drawing.color.red;                     totaltimelabel.forecolor = system.drawing.color.black;                 }             }         }     } } 

the code table below

<asp:listview id="listview1" runat="server" datasourceid="sqldatasource1" onitemdatabound="highlight_itemdatabound" >         <layouttemplate>              <table cellpadding="1" class="tablecss" runat="server" id="tblproducts">               <tr runat="server" style="background-color:lightgrey">                <th runat="server">ennotificationnoni</th>                <th runat="server">totaltime</th>                <th runat="server">tptimein</th>                <th runat="server">status</th>               </tr>               <tr runat="server" id="itemplaceholder" />             </table>         </layouttemplate>         <itemtemplate>             <tr runat="server" class="tabledata">              <td>               <asp:label id="ennotificationnoni" runat="server" text='<%#eval("ennotificationnoni") %>' />              </td>              <td>               <asp:label id="totaltime" runat="server" text='<%#eval("totaltime") %>' />              </td>              <td>               <asp:label id="tptimein" runat="server" text='<%#eval("tptimein") %>' />              </td>              <td>               <asp:label id="status" runat="server" text='<%#eval("status") %>' />              </td>             </tr>         </itemtemplate>     </asp:listview> 

try code

for entire row

control ctrl = totaltimelabel.parent.parent; htmltablerow tblrw = (htmltablerow)ctrl; tblrw.bgcolor = system.drawing.color.red.name; 

for 1 cell

control ctrl = totaltimelabel.parent; htmltablecell tblcl = (htmltablecell)ctrl; tblcl.bgcolor = system.drawing.color.red.name; 

let me know whether works :)


Comments