Gets the count of the rows in RowsCollection.
[Visual Basic] Overridable Public ReadOnly Property Count As Integer [C#] public int Count {override get;} [C++] public: __property virtual int get_Count(); [JScript] public function get Count() : int;
The following example stores the values of a single column in a temporary string variable. To iterate through the collection of DataRow objects, the example uses the Count property to specify the loop limit.
[Visual Basic]
Private Sub GetAllRows() ' Declare an array variable for DataRow objects. Dim myArray() As DataRow Dim t As DataTable Dim rc As RowsCollection ' Declare variables for a counter and temporary string. Dim i As Integer Dim sTemp As String ' Set the DataTable variable to a DataGrid control's table. Set t = DataGrid1.DataGridTable.DataTable ' Set the RowsCollection variable to the table's collection. Set rc = t.Rows For i = 0 To rc.Count - 1 sTemp &= rc(i).Item(1) & vbcrlf Next label1.Text = sTemp End Sub
RowsCollection Class | RowsCollection Members | System.Data Namespace