When you say you have an "asp table" I'm assuming you've setup something like this in your aspx page:
Code:
<asp:table id="tblTest" runat="server">
<asp:tablerow id="trTest" runat="server">
<asp:tablecell id="tdTest" runat="server">Pookie!</asp:tablecell>
</asp:tablerow>
</asp:table>
I guess it might depend on whether you use the web form designer or do your aspx/html raw (like I do)....but in your code behind there'd need to be a declaration for the asp:tablecell. For example (C#):
Code:
protected System.Web.UI.WebControls.TableCell tdTest;
This declaration may or may not exist for your asp:table depending on how you've done things. Some asp.net controls don't actually have to be declared in the code-behind to render properly. I don't use the designer and I never use asp:tables so I'm not sure exactly what would be declared via the designer.
As long as the tablecell control is declared in your code behind you can manipulate it in code behind:
Code:
tdTest.BackColor = Color.FromArgb(128, 128, 128);
As a side note, I personally just use regular html tables in my aspx pages. I tend to lean towards repeaters for building up tables via codebehind. (I'm a repeater junkie.)
I would do something more like this:
Code:
<table>
<tr>
<td id="tdTest" runat="server">
</tr>
</table>
...kind of straight html with a slight twist - the table cell (td element) is declared with an id and a runat=server...
...because you can manipulate just about anything from codebehind and the only thing I want to manipulate in that example is that one table cell. In the code behind that html element gets declared as an 'htmlcontrols' instead of a 'webcontrols':
Code:
protected System.Web.UI.HtmlControls.HtmlTableCell tdTest;
And the color manipulation is a little bit different.
Code:
tdTest.BgColor = "#EFEFEF";
*shrug* Basically two different ways to do the same thing. You lose out on a little of the OOP support with my usual way (color set as a string instead of using a color object) but for the most part the WebControls.TableCell and HtmlControls.HtmlTableCell expose the exact same properties.
Paul