asp.net.ph

DataControlFieldCollection Class

System.Web.UI.WebControls Namespace   DataControlFieldCollection Class


.NET Framework version 2.0

Represents the collection of Columns in a GridView control.

DataControlFieldCollection Class Members

Collapse   Constructors

Visibility Constructor Parameters
public DataControlFieldCollection ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public Item ( Int32 index ) DataControlField [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public Add ( DataControlField field ) Void
public CloneFields ( ) DataControlFieldCollection
public Contains ( DataControlField field ) Boolean
public CopyTo ( DataControlField array , Int32 index ) Void
protected CreateKnownType ( Int32 index ) Object
protected GetKnownTypes ( ) Type
public IndexOf ( DataControlField field ) Int32
public Insert ( Int32 index , DataControlField field ) Void
protected OnClearComplete ( ) Void
protected OnInsertComplete ( Int32 index , Object value ) Void
protected OnRemoveComplete ( Int32 index , Object value ) Void
protected OnValidate ( Object o ) Void
public Remove ( DataControlField field ) Void
public RemoveAt ( Int32 index ) Void
protected SetDirtyObject ( Object o ) Void

Collapse   Events

Multicast Name Type
multicast FieldsChanged EventHandler

Remarks

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

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

The GridView 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 GridView control's state is reload and the control is rebuilt. Otherwise, the changes to the Columns collection are not reflected in the GridView control when it is displayed.

NOTE: While you can programmatically add columns to or remove columns from the Columns collection of the GridView 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 GridView control.

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

Column Type Description
BoundField Displays a column bound to a field in a data source, that displays each row in the field as text. This is the default column type of the GridView control.
ButtonField Displays a command button for each row in the column. This allows you to create a column of custom button controls, such as the Add or Remove button.
CheckBoxField Displays a check box for each row in the GridView control. This column field type is commonly used to display fields with a Boolean value.
CommandField Displays predefined command buttons to perform selecting, editing, or deleting operations.
HyperLinkField Displays the contents of each row in the column as a hyperlink. The contents of the column can be bound to a field in a data source or static text.
ImageField Displays an image for each row in the GridView control.
TemplateField Displays each row in the column following a specified template. This allows you to provide custom controls in the column.

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

See Also

GridView   DataControlField   BoundField   ButtonField   CheckBoxField   CommandField   HyperLinkField   ImageField   TemplateField 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