Change table bgcolor programmatically

S

sam

Hello Group,
I have a table which consists of few web datagrids. Based
on certain condition, I want to change the table bgcolor from the code
behind. Any help would be great!!

Thanks,
Sam.
 
J

Jos

sam said:
Hello Group,
I have a table which consists of few web datagrids. Based
on certain condition, I want to change the table bgcolor from the code
behind. Any help would be great!!

Add the runat="server" attribute to the table tag like this:
<table id="myTable" runat="server">

From code then:
myTable.bgColor="Green"

Even better would be to create a style sheet, and change
the class for the table:

myTable.Attributes("class") = "nameOfTheGreenStyle"
 
B

Bobby Ryzhy

HTML side
<asp:Table ID="_table" Runat="server" />

CS side
protected System.Web.UI.WebControls.Table _table;

_table.BackColor = System.Drawing.Color.Turquoise;

Bobby Ryzhy
bobby@ name of domain below
http://www.weekendtech.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top