This documentation is archived and is not being maintained.

TableCell Web Server Control Declarative Syntax 

Represents a cell in a Table control and allows you to manipulate it programmatically.

    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    ForeColor="color name|#dddddd"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"

An instance of the TableCell class represents a cell in a Table control. The cells of each row are stored in the Cells collection of the TableRow representing the row. You can manipulate the contents of a cell by using the Text property.

This class allows you to control how the contents of the cell are displayed. Setting the HorizontalAlign and VerticalAlign properties specifies the horizontal and vertical alignment of the contents in the cell, respectively. You can use the Wrap property to specify whether the contents of the cell automatically continue on the next line when the end of the cell is reached.

You can also specify how many rows or columns a cell occupies in the Table control. The RowSpan and ColumnSpan properties control how many rows and columns are used, respectively.

Caution noteCaution

Text is not HTML encoded before it is displayed in the TableCell control. This makes it possible to embed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to help prevent security vulnerabilities.

For detailed information on the TableCell Web server control's properties and events, see the TableCell class documentation.

The following code example demonstrates how to create a table, add elements to the table programmatically, and display the table on the Web page. Note how TableCell controls are instantiated and their property values are set.