Export (0) Print
Expand All
0 out of 5 rated this helpful - Rate this topic

DataControlFieldCollection Class

Note: This class is new in the .NET Framework version 2.0.

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)

public sealed class DataControlFieldCollection : StateManagedCollection
public final class DataControlFieldCollection extends StateManagedCollection
public final class DataControlFieldCollection extends 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 needs to be added, removed, or changed just once instead of on each postback, as 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:

  • Use the indexer to get a single DataControlField object from the collection using array notation.

  • Use the GetEnumerator method to create a System.Collections.IEnumerator-implemented object, which can then be used to get items from the collection.

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

Description

DataControlField

The abstract base class for all fields.

BoundField

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

ButtonFieldBase

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

ButtonField

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

CheckBoxField

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

CommandField

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.

HyperLinkField

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

ImageField

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

TemplateField

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

System.Object
   System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.DataControlFieldCollection
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 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.