Home > DeveloperSection > Forums > How to change background color of table?
Tanuj Kumar

Total Post:134

Posted on    September-05-2014 12:19 AM

 ASP.Net ASP.Net 

 1 Reply(s)
 1026  View(s)
Rate this:

I want to change the background color of a table whose table tag is inside HeaderTemplate in Asp:Repeater. how can I do this?

Sumit Kesarwani

Total Post:378

Posted on    September-05-2014 1:04 AM

Hi Tanuj, 

try this:

<asp:Repeater ID="rpt" runat="server" OnItemDataBound="rpt_ItemDataBound">




                <td id="header" style="background:green;" runat="server">








                <asp:TextBox ID="ed" runat="server" autocomplete="off"></asp:TextBox>








Sample Code Behind

protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)


    if (e.Item.ItemType == ListItemType.Header)


        System.Web.UI.HtmlControls.HtmlTableCell cell = (System.Web.UI.HtmlControls.HtmlTableCell)e.Item.FindControl("header");

        cell.BgColor = "Red";



Don't want to miss updates? Please click the below button!

Follow MindStick