How to: Add Table Web Server Controls to a Web Forms Page

.NET Framework 3.0

Adding a Table Web server control consists of two steps: adding the table itself, and separately adding the rows and cells. You can add rows and columns at design time to create a static table, or you can add them at run time in code. For details about adding them at run time, see How to: Add Rows and Cells Dynamically to a Table Web Server Control.


In general, if you are creating a static table (one in which you will not add or change content at run time), it is better to use an HTML <table> element in place of a Table Web server control.

To add a Table control to a Web Forms page

To create a static table, you can add rows and cells at design time.

To add rows and cells to a Table Web server control at design time

  1. Type an <asp:TableRow> element into the page as a child of the Table control. For syntax, see Table Web Server Control and TableRow Web Server Control.

  2. For each cell in the row, type an <asp:TableCell> element into the page as a child of the TableRow control. For syntax, see TableCell Web Server Control.

  3. Repeat steps 1 and 2 for each row to add.

See Also