System.Web.UI.WebControls Namespace DetailsView Class
.NET Framework version 2.0
Returns a collection of DataControlField objects that represent the row fields in a DetailsView control.
Script |
[ DataControlFieldCollection variable = ] DetailsView.Fields |
This property can only be used programmatically; it cannot be set when declaring the control.
The property is read only with no default value.
Use this property to programmatically manage the collection of fields in the DetailsView control. The Fields collection contains explicitly declared fields that get rendered in the DetailsView control.
NOTE: Explicitly declared fields may be used in conjunction with automatically generated fields. When using both, explicitly declared fields will be rendered first, followed by the automatically generated fields. Automatically generated fields are not added to the Fields collection.
The order that the row fields are displayed in the DetailsView control is controlled by the order that the row fields appear in the Fields collection.
The following table shows the different field classes that derive from the DataControlField class and can be used in the Fields collection.
Field Type |
Description |
BoundField |
Displays a field bound to a field in a data source, that displays each row in the field as text. This is the default field type of the DetailsView control. |
ButtonField |
Displays a command button for each row in the field. This allows you to create a field of custom button controls, such as the Add or Remove button. |
CheckBoxField |
Displays a check box for each row in the DetailsView control. This field 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 field as a hyperlink. The contents of the field can be bound to a field in a data source or static text. |
ImageField |
Displays an image for each row in the DetailsView control. |
TemplateField |
Displays each row in the field following a specified template. This allows you to provide custom controls in the field. |
NOTE: While you can programmatically add fields to the Fields collection, it is easier to list the row fields declaratively and then use the Visible property to show or hide the field.
DetailsView Members DataControlField BoundField ButtonField CheckBoxField CommandField HyperLinkField ImageField TemplateField