TableRow row = new TableRow(); // Adding cell 1 TableCell cell1 = new TableCell(); cell1.Text = "John"; row.Cells.Add(cell1); // Adding cell 2 TableCell cell2 = new TableCell(); cell2.Text = "Doe"; row.Cells.Add(cell2); // Adding row to table myTable.Rows.Add(row);
TableRow row = new TableRow(); row.Attributes.Add("class", "highlight"); // Adding cells to the row // ...In this example, the class attribute of the TableRow object is set to "highlight" which can be used to apply custom CSS styles to the row. Package library: This class is a part of the System.Web assembly which is included in the .NET Framework and can be accessed by including the System.Web namespace in the code.