---
title: "How to change background color of table?"  
description: "How to change background color of table?"  
author: "Anonymous User"  
published: 2014-09-05  
updated: 2014-09-05  
canonical: https://www.mindstick.com/forum/2251/how-to-change-background-color-of-table  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How to change background color of table?

I want to change the [background color](https://www.mindstick.com/forum/12937/how-to-style-togglebutton-so-that-the-background-color-is-white) of a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) whose table tag is inside HeaderTemplate in [Asp](https://www.mindstick.com/articles/751/introduction-to-asp-dot-net-mvc):Repeater. how can I do this?

## Replies

### Reply by Sumit Kesarwani

Hi Tanuj, \
try this:\

```
<asp:Repeater ID="rpt" runat="server" OnItemDataBound="rpt_ItemDataBound">   
<HeaderTemplate>        <table>            <tr>                <td id="header" style="background:green;"runat="server">                   
textBox               
</td>           
</tr>   
</HeaderTemplate>   
<ItemTemplate>        <tr>            <td>               
<asp:TextBox ID="ed" runat="server" autocomplete="off"></asp:TextBox>           
</td>        </tr>   
</ItemTemplate>   
<FooterTemplate>        </table>   
</FooterTemplate></asp:Repeater>
```

## 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";    }}
```


---

Original Source: https://www.mindstick.com/forum/2251/how-to-change-background-color-of-table

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
