System.Web.UI.HtmlControls Namespace HtmlTableCell Class
Sets or retrieves the number of rows that the HtmlTableCell control spans.
Inline |
<th | td rowspan = intRows ... > |
Script |
HtmlTableCell.RowSpan [ = intRows ] |
intRows |
Integer specifying the number of rows the HtmlTableCell occupies. |
The property is read/write with a default value of -1 ( not enabled ).
Cells can be merged, or can span rows or columns.
Use the RowSpan property to specify how many rows in the HtmlTable the cell should span. This allows you to create a cell in the table that occupies more than one row.
When spanning rows, be sure to define one less cell in the column for each row that you span, as shown in the sample below. Otherwise, that column will have more than the number of rows in the table and the table will not be rendered as expected.
NOTE: Specifying a zero value for RowSpan means that the cell spans all rows from the current row to the last row of the table in which the cell is defined.
The following shows how to declaratively set the RowSpan property of an HtmlTableCell at design time.
<table width="70%" align="center" border=1 cellpadding=10 runat="server">
<tr>
<th rowspan=3>This header<br> spans 3 rows</th>
<td>Cell 1</td>
<td>Cell 2</td></tr>
<tr>
<td>Cell 3</td>
<td>Cell 4</td></tr>
<tr>
<td>Cell 5</td>
<td>Cell 6</td></tr>
</table>
Which would render as follows:
This header spans 3 rows |
Cell 1 |
Cell 2 |
Cell 3 | Cell 4 |
Cell 5 | Cell 6 |
Notice that in the second and third rows, we only have two <td> elements each. This is because the <th> in the first row, with its RowSpan set to 3, already occupies, or spans, the first cells of each row.
HtmlTableCell Members ColSpan