how to convert these html tags into <asp:table> in c#?

liunx

Guest
Hi, this needs to be done programmatically in code-behind using Table class. No aspx code allowed.

html format:

<table>
<tr bgcolor="#2E8B57">
<td width="100" align="center" bgcolor="9ACD32"><font color = "Black"></b>One</b></font></td>
<td width="100" align="center" bgcolor="9ACD32"><font color = "Black"></b>Two</b></font></td>
<td width="100" align="center" bgcolor="#2f4f4f"><font color = "Yellow"><b>Three</b></font></td>
<td width="100" align="center" bgcolor="9ACD32"><font color = "Black"></b>Four</b></font></td>
<td width="100" align="center" bgcolor="9ACD32"><font color = "Black"></b>Five</b></font></td>
</tr>
</table>


problem I'm experiencing atm:

TableCell cellNew = null;
for (int cols = 0; cols< col; cols++){
cellNew = new TableCell();
cellNew.ForeColor = "Yellow";
cellNew.BackColor="Green";
cellNew.Text = "One";
rowNew.Controls.Add(cellNew);
}


line 4 and 5 is not working.
TIAI am assuming you are referring to these 2 lines.

cellNew.ForeColor = "Yellow";
cellNew.BackColor="Green";

"Yellow" and "Green" is NOT a color. They are strings.

You need, Color.yellow, and Color.Green like this.

cellNew.ForeColor = Color.Yellow
cellNew.BackColor= Color.Green

Tak
 
Back
Top