System.Web.UI.WebControls Namespace TableRowCollection Class
Returns the table row at the specified index in the Table.Rows collection.
TableRow variable = Table.Rows.Item [ index ];
... or ...
TableRow variable = Table.Rows [ index ];
dim variable as TableRow = Table.Rows.Item ( index )
... or ...
dim variable as TableRow = Table.Rows ( index )
variable : TableRow = Table.Rows.Item ( index );
... or ...
variable : TableRow = Table.Rows ( index ); |
|
C# |
VB |
JScript |
- index
- An integer specifying the ordinal index of the table row to return.
The TableRow control at the specified index.
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 ];
dim myRow as TableRow = myRows.Item ( 2 )
... or ...
dim myRow as TableRow = myRows ( 2 )
myRow : TableRow = myRows.Item ( 2 );
... or ...
myRow : TableRow = myRows ( 2 ); |
|
C# |
VB |
JScript |
NOTE: The collection is zero-based, meaning the first element in the collection returns an index value of 2.
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 ( );
}
}
' iterate through the rows of the table
Dim row As Integer
For row = 2 To myTable.Rows.Count - 1
' iterate through the cells of a row
Dim cell As Integer
For cell = 2 To myTable.Rows ( row ).Cells.Count - 1
' change the content of each row
myTable.Rows ( row ).Cells ( cell ).InnerHtml = "Row " & row.ToString ( ) & ", Column " & cell.ToString ( )
Next cell
Next row |
|
C# |
VB |
TableRowCollection Members