asp.net.ph

DataGridColumnCollection.Count Property

System.Web.UI.WebControls Namespace   DataGridColumnCollection Class


Returns the number of columns in the collection.

Syntax


Script [ integer variable = ] DataGridColumnCollection.Count

Property Value


variable Integer specifying the total number of columns currently stored in the collection.

The property is read only with no default value.

Remarks

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.

Example

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

See Also

DataGridColumnCollection Members Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note