asp.net.ph

TableCellCollection.Item Property

System.Web.UI.WebControls Namespace   TableCellCollection Class


Returns the table cell at the specified index in the TableRow.Cells collection.

Syntax


TableCell variable = TableRow.Cells.Item [ index ];
... or ...
TableCell variable = TableRow.Cells [ index ];
  C# VB JScript

Parameters

index
An integer specifying the ordinal index of the table cell to return.

Return Value

The TableCell control at the specified index.

Remarks

Use this indexer to get a TableCell from the TableCellCollection. You can access a TableCell at a specified index by using simple array notation.

For example, if you have a TableCellCollection called myCellCollection, you can access the first element in the collection by using the following statement:

TableCell myCell = myCellCollection.Item [ 0 ];
... or ...
TableCell myCell = myCellCollection [ 0 ];
  C# VB JScript

NOTE: The collection is zero-based, meaning the first element in the collection returns an index value of 0.

Example

The following example demonstrates how to use the indexer to retrieve a cell in the TableRow.Cells collection. The cell is then updated with new content.

// iterate through the rows of the table

for ( int r = 0; r < myTable.Rows.Count; r++ ) {
   // iterate through the cells of a row

   for ( int c = 0; c < myTable.Rows [ r ].Cells.Count; c++ ) {
      // change the content of each cell
      myTable.Rows [ r ].Cells [ c ].InnerHtml = "Row " + r.ToString ( ) + ", Column " + c.ToString ( ); 
   }
}
  C# VB

See Also

TableCellCollection 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