Table,TableRow and TableCell Web Server Control
in ASP.NET environment,This article describes you how to work with Table,TableRow
and TableCell Web Control.The table,TableRow and TableCell are similar to the HTML
elements.The Table Web server control creates a general-purpose table on a Web Forms
Rows in the table are created as TableRow Web server controls, and cells within
each row are implemented as TableCell Web server controls.
Web Server Table Vs Html Table
- HTML table.enables you to create a static table in a web page by specify
<table> element.you create HTML table when you are creating a static table
(one in which you will not add or change content at run time), do not create a Table
- a <HTMLTable> can became a Table control when including the runat=server property
- Table that allows you to create and manipulate tables. for instance, adding
rows or cells via server code.
The Table Web server control can be easier to program than the HtmlTable control
because it offers an object model with typed properties that is consistent with
other Web server controls. (The model is also consistent between the Table, TableRow,
and TableCell controls.)
Web Server Table Vs Other List Web Server Controls
Binding Data to the Table Control
- he list controls are data-bound. The list controls work only against a data source,
whereas the Table control can display any combination of HTML text and controls,
whether or not they are data-bound.
- The list controls use templates to specify the layout of their elements. The Table
control supports the TableCell child control, which you can fill as you would any
HTML <td> element.
Although the Table control is not inherently data-bound, you can use it to display
data from a database.you can bind any property of a Table control to a data source
like as all other web control.
To Add Table Web Server Controls to a Page
To add rows and cells to a Table Web server control at design time
- Type <asp:Table></asp:Table> element in a Page
- (or) From the Standard tab of the Toolbox, drag a Table control onto the page.
To add rows and cells to a Table Web server control Programmatically,
- Select the table, then open the Properties window and click the ellipsis button(..)
for the Rows property.
- Click Add to create a new row.
- To add cells to the new row, make sure the row is selected in the Members list,
and then click the ellipsis button (..) for the Cells property.
- Click Add to create a new cell
the following code snippets demonstrates create rows and columns at run time.