ASP.NETBuild the Table One Row at a Time
Listing 1. Add a row to your table by first creating a TableRow object, then adding TableCells. Add the TableRow to the Table object once you've created all the cells. Set the Row and Cell properties to the desired values before adding them to the TableRow. ![]() TableRow r = new TableRow(); // build the title row TableCell c = new TableCell(); c.CssClass = "ItemSubHead"; c.BackColor = Color.BurlyWood; c.Text="League"; c.Width = 225; r.Cells.Add(c); c = new TableCell(); c.CssClass = "ItemSubHead"; c.BackColor = Color.BurlyWood; c.Text="Date"; c.Width = 180; r.Cells.Add(c); c = new TableCell(); c.CssClass = "ItemSubHead"; c.BackColor = Color.BurlyWood; c.Text="Time"; c.Width = 180; r.Cells.Add(c); tblClasses.Rows.Add(r); |