Export (0) Print
Expand All

DataControlFieldCollection Class

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

System.Object
  System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.DataControlFieldCollection

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

public sealed class DataControlFieldCollection : StateManagedCollection

The DataControlFieldCollection type exposes the following members.

  NameDescription
Public methodDataControlFieldCollectionInitializes a new instance of the DataControlFieldCollection class.
Top

  NameDescription
Public propertyCountGets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public propertyItemGets or sets the DataControlField object at the specified index in the collection.
Top

  NameDescription
Public methodAddAppends the specified DataControlField object to the end of the collection.
Public methodClearRemoves all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodCloneFieldsCreates a copy of the current collection.
Public methodContainsDetermines whether the DataControlFieldCollection collection contains a specific DataControlField object.
Public methodCopyTo(Array, Int32)Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index. (Inherited from StateManagedCollection.)
Public methodCopyTo(DataControlField[], Int32)Copies the entire DataControlFieldCollection collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetEnumeratorReturns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfDetermines the index of a specific DataControlField object in the collection.
Public methodInsertInserts the specified DataControlField object into the DataControlFieldCollection collection at the specified index.
Public methodRemoveRemoves the specified DataControlField object from the DataControlFieldCollection collection.
Public methodRemoveAtRemoves the DataControlField object at the specified index from the DataControlFieldCollection collection.
Public methodSetDirtyForces the entire StateManagedCollection collection to be serialized into view state. (Inherited from StateManagedCollection.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventFieldsChangedOccurs when the fields in the collection change, usually as the result of a Clear, Insert, Remove or Add method call. This event is also raised anytime a DataControlField in the collection raises its FieldChanged event.
Top

  NameDescription
Explicit interface implemetationPrivate propertyICollection.CountInfrastructure. Gets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedInfrastructure. Gets a value indicating whether the StateManagedCollection collection is synchronized (thread safe). This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the StateManagedCollection collection. This method returns null in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorInfrastructure. Returns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.AddAdds an item to the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.ClearInfrastructure. Removes all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the StateManagedCollection collection contains a specific value. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.IndexOfDetermines the index of a specified item in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.InsertInserts an item into the StateManagedCollection collection at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList.IsFixedSizeInfrastructure. Gets a value indicating whether the StateManagedCollection collection has a fixed size. This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList.IsReadOnlyInfrastructure. Gets a value indicating whether the StateManagedCollection collection is read-only. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList.ItemInfrastructure. Gets the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.RemoveRemoves the first occurrence of the specified object from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.RemoveAtRemoves the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIStateManager.IsTrackingViewStateGets a value indicating whether the StateManagedCollection collection is saving changes to its view state. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager.LoadViewStateRestores the previously saved view state of the StateManagedCollection collection and the IStateManager items it contains. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager.SaveViewStateSaves the changes to the StateManagedCollection collection and each IStateManager object it contains since the time the page was posted back to the server. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager.TrackViewStateCauses the StateManagedCollection collection and each of the IStateManager objects it contains to track changes to their view state so they can be persisted across requests for the same page. (Inherited from StateManagedCollection.)
Top

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:

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 displays a HyperLink control.

ImageField

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

TemplateField

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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