System.Web.UI.WebControls Namespace GridViewRowCollection Class
.NET Framework version 2.0
Returns an IEnumerator interface that contains all the GridViewRow objects in the collection.
[ VB ]
NotOverridable Public Function GetEnumerator ( ) As IEnumerator
[ C# ]
public IEnumerator GetEnumerator ( );
[ C++ ]
public: __sealed IEnumerator* GetEnumerator ( );
[ JScript ]
public function GetEnumerator ( ) : IEnumerator;
A System.Collections.IEnumerator that contains a list of GridViewRow objects in the collection.
Use this method to create a System.Collections.IEnumerator that can be iterated through easily to get each row in the GridViewRowCollection.
Use the IEnumerator.Current property to get the row currently pointed to in the collection.
Use the IEnumerator.MoveNext method to move to the next row in the collection.
Use the IEnumerator.Reset method to move the enumerator to the initial position.
NOTE: The IEnumerator.MoveNext method must be called after creating a System.Collections.IEnumerator object, or after using the IEnumerator.Reset method to move the enumerator to the first row in the collection. Otherwise, the row represented by the IEnumerator.Current property is undefined.
The following example demonstrates how to use the GetEnumerator method to create an IEnumerator interface that can be interated though to display the contents of the GridViewRowCollection.
void getEnumerator ( Object src, EventArgs e ) {
// create IEnumerator for rows.
IEnumerator myEnum = myGrid.Rows.GetEnumerator ( );
GridViewRow item;
// iterate through IEnumerator and display the text for the first cell of each item
while ( myEnum.MoveNext ( ) ) {
row = ( GridViewRow ) myEnum.Current;
myLabel.Text += row.Cells [ 0 ].Text + "<br>";
}
}
Sub getEnumerator ( src As Object, e As EventArgs )
' create IEnumerator for rows.
Dim myEnum As IEnumerator = myGrid.Rows.GetEnumerator ( )
Dim row As GridViewRow
' iterate through IEnumerator and display the text for the first cell of each item
While myEnum.MoveNext ( )
row = CType ( myEnum.Current, GridViewRow )
myLabel.Text &= row.Cells [ 0 ].Text & "<br>"
End While
End Sub |
|
C# |
VB |
Show me
GridViewRowCollection Members