asp.net.ph

HtmlTableRowCollection.Item Property

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 );

Parameters

index
The index of the table row object to be returned.

Return Value

The specified HtmlTableRow control.

Remarks

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 ];
  C# VB

Example

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";
   }
}
See Also

HtmlTableRowCollection 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