asp.net.ph

HtmlTableCellCollection.Count Property

System.Web.UI.HtmlControls Namespace   HtmlTableCellCollection Class


Returns the number of table cell objects in the HtmlTableRow.Cells collection.

Syntax


Script [ integer intVar = ] Cells.Count

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


intVar Integer object representing the number of cells in the collection.

The property is read-only with no default value.

Remarks

Use the Count property to determine the number of HtmlTableCell objects contained in the HtmlTableCellCollection. Count is commonly used when iterating through the cells of a table row to determine the upper bound of a loop.

Example

The following example demonstrates how to use the Count property to determine the number of cells in a row of an HtmlTable. This value is then used as the upper bound of a loop to iterate through the cells of the row.

// iterate through the rows of the table
for ( int r = 0; r <= myTable.Rows.Count - 1; r++ ) {

   // iterate through the cells of a row
   for ( int c = 0; c <= myTable.Rows [ r ].Cells.Count - 1; c++ ) {

      // change the content of each cell
      myTable.Rows [ r ].Cells [ c ].InnerHtml = "Row " + r.ToString ( ) + 
         ", Column " + c.ToString ( ); 
   }
}
See Also

HtmlTableCellCollection Members 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