Wednesday, September 16, 2009

Dynamic create table using code behind

Table table = new Table();

for (int j = 1; j < 4; j++)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
// Add the control to the TableCell
string Temp = j==1 ? str1 : j==2 ? str2 : j==3 ? str3 : "";
cell.Text = Temp;
row.Controls.Add(cell);
table.Rows.Add(row);
}
this.Page.Controls.Add(table);

No comments:

Post a Comment