Jaa


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

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.

Note

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 Web server control to a Web Forms page

  • From the Standard tab of the Toolbox, drag a Table control onto the page.

    The table is initially displayed as a simple text control with no rows or columns.

Adding Table Rows and Cells at Design Time

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. Select the table, and then open the Properties window and click the ellipsis button (VisualStudioEllipsesButton screenshot) for the Rows property.

    The TableRow Collection Editor window is displayed.

  2. Click Add to create a new row.

    A new row is added, and its properties are displayed in a grid on the right-hand side of the dialog box.

  3. Optionally, set display characteristics for the new row by changing its font, color, and so on.

    Note

    Settings you enter in the TableRow Collection Editor dialog box apply to only one row. To apply settings that apply to all rows, set properties for the table as a whole.

  4. To add cells to the new row, make sure the row is selected in the Members list, and then click the ellipsis button (VisualStudioEllipsesButton screenshot) for the Cells property.

    The TableCell Collection Editor dialog box is displayed.

  5. Click Add to create a new cell, and set its properties using the grid on the right-hand side of the dialog box. To display text in the cell, set its Text property.

  6. Repeat step 5 for each cell you want to add to a row. When you are finished adding cells to a row, click OK in the TableCell Collection Editor dialog box.

  7. Repeat steps 2 through step 6 for each new row and its cells. When you are finished adding rows to the table, click OK in the TableRow Collection Editor dialog box.

    The Table control is displayed in Design view with placeholder characters for each row and cell that you have created.

See Also

Reference

Table, TableRow, and TableCell Web Server Control Overview