System.Web.UI.HtmlControls Namespace HtmlTableRowCollection Class
Returns the table row object at the specified index from the Rows collection.
In [ C# ], this property is the indexer for the HtmlTableRowCollection class.
[ VB ]
Public Default ReadOnly Property Item ( _
ByVal index As Integer _
) As HtmlTableRow
[ C# ]
public HtmlTableRow this [
int index
] {get;}
[ C++ ]
public: __property HtmlTableRow* get_Item (
int index
);
[ JScript ]
returnValue=HtmlTableRowCollectionObject.Item ( index );
-or-
returnValue=HtmlTableRowCollectionObject ( index );
- index
- The index of the table row object to be returned.
The specified HtmlTableRow control.
Use this indexer to get an HtmlTableRow from the HtmlTableRowCollection. You can access an HtmlTableRow at a specified index by using simple array notation.
NOTE: The collection is zero-based, meaning the first element in the collection returns an index value of 0.
For example, to access the first element in the collection, use the following statement:
HtmlTableRow myRow = myTable.Rows [ 0 ];
Dim myRow As HtmlTableRow = myTable.Rows ( 0 ) |
|
C# |
VB |
The following example demonstrates how to use the indexer to refer to individual table row objects in the HtmlTableRowCollection. In this sample, a background color is applied to every other row.
// iterate through the rows of the table
for ( int r = 0; r <= myTable.Rows.Count - 1; r++ ) {
// set the bgcolor only for alternate rows
if ( r%2 == 1 ) {
myTable.Rows [ r ].BgColor = "beige";
}
}
HtmlTableRowCollection Members