System.Web.UI.WebControls Namespace GridViewRowCollection Class
.NET Framework version 2.0
Copies the contents of the collection into an Array, starting at the specified index of the Array object.
[ VB ]
NotOverridable Public Sub CopyTo ( _
ByVal array As Array, _
ByVal index As Integer _
)
[ C# ]
public void CopyTo (
Array array,
int index
);
[ C++ ]
public: __sealed void CopyTo (
Array* array,
int index
);
[ JScript ]
public function CopyTo (
array : Array,
index : int
);
- array
- A System.Array object to copy the contents of the collection into.
- index
- The zero-based index of the Array to begin copying the contents of the collection into.
Use this method to copy the contents of the GridViewRowCollection into the specified System.Array object, starting at the specified index.
NOTE: The array parameter must be a zero-based System.Array object.
The following example demonstrates how to use the CopyTo method to copy the contents of the GridViewRowCollection to an array of GridViewRow objects.
void copyTo ( Object src, EventArgs e ) {
GridViewRow [ ] myArray = new GridViewRow [ myGrid.Rows.Count ];
myGrid.Rows.CopyTo ( myArray, 0 );
// Display the text for the first cell of each row in the array
foreach ( GridViewRow row in myArray ) {
myLabel.Text += row.Cells [ 0 ].Text + "<br>";
}
}
Sub copyTo ( src As Object, e As EventArgs )
Dim myArray ( 3 ) As GridViewRow
myGrid.Rows.CopyTo ( myArray, 0 )
' Display the text for the first cell of each row in the array
Dim row As GridViewRow
For Each row In myArray
myLabel.Text &= row.Cells [ 0 ].Text & "<br>"
Next row
End Sub |
|
C# |
VB |
GridViewRowCollection Members