asp.net.ph

DataGridColumnCollection Class

System.Web.UI.WebControls Namespace   DataGridColumnCollection Class


Represents the collection of Columns in a DataGrid control.

DataGridColumnCollection Class Members

Collapse   Constructors

Visibility Constructor Parameters
public DataGridColumnCollection ( DataGrid owner , ArrayList columns )

Collapse   Properties

Visibility Name Value Type Accessibility
public Count Int32 [ Get ]
public IsReadOnly Boolean [ Get ]
public IsSynchronized Boolean [ Get ]
public Item ( Int32 index ) DataGridColumn [ Get ]
public SyncRoot Object [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public Add ( DataGridColumn column ) Void
public AddAt ( Int32 index , DataGridColumn column ) Void
public Clear ( ) Void
public CopyTo ( Array array , Int32 index ) Void
public GetEnumerator ( ) IEnumerator
public IndexOf ( DataGridColumn column ) Int32
public Remove ( DataGridColumn column ) Void
public RemoveAt ( Int32 index ) Void

Remarks

Use the DataGridColumnCollection to programmatically manage a collection of DataGridColumn derived column objects. These objects represent the columns in a DataGrid control. You can add, remove, or insert columns into the DataGridColumnCollection.

NOTE: When the AutoGenerateColumns property is set to true, the columns created by the DataGrid control are not added to the Columns collection.

The DataGrid control does not store the contents of its Columns collection into the view state. To add or remove a column dynamically, you must programmatically add or remove the column everytime the page is refreshed. Provide a Page_Init function that adds or removes the column before the DataGrid control's state is reload and the control is rebuilt. Otherwise, the changes to the Columns collection are not reflected in the DataGrid control when it is displayed.

NOTE: While you can programmatically add columns to or remove columns from the Columns collection of the DataGrid control, it is easier to list the columns statically and then use the Visible property to display or hide each column.

The order of the columns in the collection determines the order that the columns are displayed in the DataGrid control.

The following table lists the different column classes that derive from the DataGridColumn class.

Column Class Description
BoundColumn A column that is bound to a field in a data source. It displays each item in the field as text. This is the default column type for the DataGrid control.
ButtonColumn A column that displays a command button for each item in the column. This allows you to create a column of custom button controls, such as Add or Remove buttons.
EditCommandColumn A column that contains editing commands for each item in the column.
HyperLinkColumn A column that displays each item in the column as a hyperlink. The contents of the column can be bound to a field in a data source, or to static text.
TemplateColumn A column that displays each item in the column according to a specified template. This allows you to control the content of the column, such as displaying images.

NOTE: The DataGridColumn class is the base class for the column classes listed. It is not used directly in the DataGridColumnCollection.

See Also

DataGrid   Columns   BoundColumn   ButtonColumn   EditCommandColumn   HyperLinkColumn   TemplateColumn Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

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

You can help support asp.net.ph