asp.net.ph

TableRowCollection.Item Property

System.Web.UI.WebControls Namespace   TableRowCollection Class


Returns the table row at the specified index in the Table.Rows collection.

Syntax


TableRow variable = Table.Rows.Item [ index ];
... or ...
TableRow variable = Table.Rows [ index ];
  C# VB JScript

Parameters

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

Return Value

The TableRow control at the specified index.

Remarks

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

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

TableRow myRow = myRows.Item [ 2 ];
... or ...
TableRow myRow = myRows [ 2 ];
  C# VB JScript

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

Example

The following example demonstrates how to use the indexer to retrieve a row in the Table.Rows collection. The row is then updated with new content.

// iterate through the rows of the table

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

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

See Also

TableRowCollection 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