System.Web.UI.WebControls.DetailsView.Fields Property

Gets a collection of System.Web.UI.WebControls.DataControlField objects that represent the explicitly declared row fields in a System.Web.UI.WebControls.DetailsView control.

Syntax

[System.ComponentModel.DefaultValue(null)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.ComponentModel.MergableProperty(false)]
[System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataControlFieldTypeEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public virtual DataControlFieldCollection Fields { get; }

Value

Documentation for this section has not yet been entered.

Remarks

When you explicitly declare the row fields for a System.Web.UI.WebControls.DetailsView control, these row fields are stored in the DetailsView.Fields property (collection). The DetailsView.Fields collection also allows you to programmatically manage the collection of explicitly declared rows.

Note:

Explicitly declared row fields can be used in combination with automatically generated row fields. When both are used, explicitly declared row fields are rendered first, followed by the automatically generated row fields. Automatically generated row fields are not added to the DetailsView.Fields collection.

Different row field types determine the behavior of the rows in the control. The following table shows the different row field types that can be used in the DetailsView.Fields collection.

System.Web.UI.WebControls.BoundField

Displays the value of a field in a data source as text.

System.Web.UI.WebControls.ButtonField

Displays a command button in the System.Web.UI.WebControls.DetailsView control. This allows you to display a row with a custom button control, such as an Add or a Remove button.

System.Web.UI.WebControls.CheckBoxField

Displays a check box in the System.Web.UI.WebControls.DetailsView control. This row field type is commonly used to display fields with a Boolean value.

System.Web.UI.WebControls.CommandField

Displays built-in command buttons to perform edit, insert, or delete operations in the System.Web.UI.WebControls.DetailsView control.

System.Web.UI.WebControls.HyperLinkField

Displays the value of a field in a data source as a hyperlink. This row field type allows you to bind a second field to the hyperlink's URL.

System.Web.UI.WebControls.ImageField

Displays an image in the System.Web.UI.WebControls.DetailsView control.

System.Web.UI.WebControls.TemplateField

Displays user-defined content for a row in the System.Web.UI.WebControls.DetailsView control according to a specified template. This row field type allows you to create a custom row field.

To explicitly declare the row fields for a System.Web.UI.WebControls.DetailsView control, first set the DetailsView.AutoGenerateRows property to false. Next, add opening and closing <Fields> tags between the opening and closing tags of the System.Web.UI.WebControls.DetailsView control. Finally, list the row fields that you want to include between the opening and closing <Fields> tags. The row fields are displayed in the System.Web.UI.WebControls.DetailsView control in the order that the row fields appear in the DetailsView.Fields collection.

Although you can programmatically add row fields to the DetailsView.Fields collection, it is easier to list the row fields declaratively in the System.Web.UI.WebControls.DetailsView control and then use the DataControlField.Visible property of each row field to show or hide the row field.

If the DataControlField.Visible property of a row field is set to false, the row is not displayed in the System.Web.UI.WebControls.DetailsView control and the data for the row does not make a round trip to the client. If you want the data for a row that is not visible to make a round trip, add the field name to the DetailsView.DataKeyNames property.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0