asp.net.ph

TableCell.ColumnSpan Property

System.Web.UI.WebControls Namespace   TableCell Class


Sets or retrieves the number of columns that the TableCell control spans.

Syntax


Inline <asp:tablecell columnspan = intCols ... >
Script TableCell.ColumnSpan [ = intCols ]

Property Value


intCols Integer specifying the number of columns the TableCell occupies.

The property is read/write with a default value of -1 ( not enabled ).

Remarks

Cells can be merged, or can span columns or rows.

Use the ColumnSpan property to specify how many columns in the Table the cell should span. This allows you to create a cell in the table that occupies more than one column.

When spanning columns, be sure to define one less cell in the row for each column that you span, as shown in the sample below. Otherwise, that row will have more than the number of columns in the table and the table will not be rendered as expected.

NOTE: Specifying a zero value for ColumnSpan means that the cell spans all columns from the current column to the last column of the column group in which the cell is defined.

Example

The following shows how to declaratively set the ColumnSpan property of a TableCell at design time.

<asp:table width = "70%" runat = "server"
      horizontalalign = "center" gridlines = "both" cellpadding=10>
   <asp:tablerow>
      <asp:tableheadercell columnspan=3>
         This header spans 3 columns
      </asp:tableheadercell>
   </asp:tablerow>
   <asp:tablerow>
      <asp:tablecell>Cell 1</asp:tablecell>
      <asp:tablecell>Cell 2</asp:tablecell>
      <asp:tablecell>Cell 3</asp:tablecell>
   </asp:tablerow>
   <asp:tablerow>
      <asp:tablecell>Cell 4</asp:tablecell>
      <asp:tablecell>Cell 5</asp:tablecell>
      <asp:tablecell>Cell 6</asp:tablecell>
   </asp:tablerow>
</asp:table>

Which would render as follows:

This header spans 3 columns
Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6

Notice that instead of having three <asp:tableheadercell> elements for the first row, here we only have one <asp:tableheadercell> with its ColumnSpan attribute set to 3. This tells the browser that this <asp:tableheadercell> occupies, or spans, three columns contained in the row.

See Also

TableCell Members   RowSpan 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