This documentation is archived and is not being maintained.

DataControlFieldCollection Class

Represents a collection of DataControlField objects that are used by data-bound controls such as GridView and DetailsView.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class DataControlFieldCollection : StateManagedCollection

The DataControlFieldCollection class represents a collection of DataControlField objects used by data-bound controls to specify how their child controls are presented. The DataControlFieldCollection class derives from StateManagedCollection, an abstract base collection class used specifically to store IStateManager objects.

A StateManagedCollection object influences the behavior of a DataControlFieldCollection object. DataControlField objects that are dynamically added to the collection will be re-added to the control when state is restored. This means that a field must be added, removed, or changed just once instead of on each postback, the way most collection types in ASP.NET require.

(The DataControlField class implements the IStateManager interface, which enables it to store its state in ASP.NET view state. )

Use the DataControlFieldCollection class to programmatically manage a set of DataControlField objects. Note that it is more common to define these fields declaratively.

You can add, insert, and remove DataControlField objects using the appropriate methods of the DataControlFieldCollection class. To programmatically retrieve DataControlField objects from a collection, use one of following methods:

The Count property specifies the total number of items in the collection, and is commonly used to determine the upper bound of the collection. You can add items to and remove items from the collection using the Add, Insert, Remove, and RemoveAt methods.

If you are using the GridView or DetailsView control, the DataControlField objects that are automatically created (for example, when the AutoGenerateColumns property is true) are not stored in the publicly accessible fields collection. You can only access and manipulate DataControlField objects that are not automatically generated.

The following table lists the different data control field classes and how they are used.

Parameter Class



The abstract base class for all fields.


A data-bound control field that is used to bind to text or data retrieved from an ASP.NET data source control.


A data-bound control field that encapsulates general button functionality. ButtonField and CheckBoxField are derived from it.


A data-bound control field that displays at least one button.


A data-bound control field that displays a CheckBox control.


A data-bound control field that displays actions that can be performed on the data displayed by the row (or column), such as edit, update, or delete.


A data-bound control field that displays a HyperLink control.


A data-bound control field that displays an Image control.


A data-bound control field that displays custom content in a data-bound control.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0