System.Web.UI.WebControls Namespace DataGridColumnCollection Class
Returns the number of columns in the collection.
Script |
[ integer variable = ] DataGridColumnCollection.Count |
variable |
Integer specifying the total number of columns currently stored in the collection. |
The property is read only with no default value.
Use the Count property to determine the number of columns in the DataGridColumnCollection. The Count property is commonly used when iterating through the collection to determine the upper bound of the collection.
The following example demonstrates how to use the Count property to determine the upper bound of the DataGridColumnCollection. This value is then used to iterate though the collection.
void showHeaders ( Object src, EventArgs e ) {
myLabel.Text = "Header Text for each column: <br>";
for ( int i = 0; i < myGrid.Columns.Count; i ++ ) {
myLabel.Text += myGrid.Columns [ i ].HeaderText + "<br>";
}
}
Sub Button_Click ( src As Object, e As EventArgs )
myLabel.Text = "Header Text for each column: <br>"
Dim i As Integer
For i = 0 To myGrid.Columns.Count - 1
myLabel.Text &= myGrid.Columns ( i ).HeaderText & "<br>"
Next i
End Sub |
|
C# |
VB |
DataGridColumnCollection Members