asp.net.ph

Table Class

System.Web.UI.WebControls Namespace


Constructs a table and defines its properties.

Table Class Members

Collapse   Constructors

Visibility Constructor Parameters
public Table ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public BackImageUrl String [ Get , Set ]
public Caption String [ Get , Set ]
public CaptionAlign TableCaptionAlign [ Get , Set ]
public CellPadding Int32 [ Get , Set ]
public CellSpacing Int32 [ Get , Set ]
public GridLines GridLines [ Get , Set ]
public HorizontalAlign HorizontalAlign [ Get , Set ]
public Rows TableRowCollection [ Get ]
public SupportsDisabledAttribute Boolean [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
protected AddAttributesToRender ( HtmlTextWriter writer ) Void
protected CreateControlCollection ( ) ControlCollection
protected CreateControlStyle ( ) Style
protected RaisePostBackEvent ( String argument ) Void
public RenderBeginTag ( HtmlTextWriter writer ) Void

Remarks

The Table class allows you to build an HTML table and specify its characteristics in a straightforward manner, using the same abstract object model for building any other Web controls. A table can be built at design time given some static contents, but the power of a Table control is often realized when the table is built programmatically with dynamic contents. In addition, as for other Web controls, the same code to render a table yields appropriate output accordingly for both downlevel and uplevel browsers.

Example 1 illustrates how to create a table at design time. The TableRow and TableCell Web controls are also used in the process. In this example, the table contains 2 rows of 2 cells each, with both horizontal and vertical gridlines, and is aligned to the center of the page.

Example 2 illustrates how to construct a table programmatically. First, you add contents to a table cell by adding ( literal controls, and so on ) to its Controls collection. Then you add TableCell objects to the table row's Cells collection. After that, you add the TableRow objects to the table's Rows collection. For this example, constants are assigned to the number of rows and columns, but often they come from user input controls ( such as ListBox, and so on ).

It is important to remember that any programmatic addition or modification of table rows or cells will not persist across postbacks. It is because table rows and cells are controls of their own, and not properties of controls. Therefore, any changes of table rows or cells should be reconstructed after each postback. In fact, if substantial modifications are expected, it is recommended that DataList or DataGrid controls be used instead of Table controls. As a result, this Table class is primarily used by control developers.

Skip Navigation Links



Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph