System.Web.UI.WebControls.GridView.AutoGenerateColumns Property

Gets or sets a value indicating whether bound fields are automatically created for each field in the data source.

Syntax

[System.ComponentModel.DefaultValue(true)]
public virtual bool AutoGenerateColumns { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

When the GridView.AutoGenerateColumns property is set to true, an System.Web.UI.WebControls.AutoGeneratedField object is automatically created for each field in the data source. Each field is then displayed as a column in the System.Web.UI.WebControls.GridView control in the order that the fields appear in the data source. This option provides a convenient way to display every field in the data source; however, you have limited control of how an automatically generated column field is displayed or behaves.

Instead of letting the System.Web.UI.WebControls.GridView control automatically generate the column fields, you can manually define the column fields by setting the GridView.AutoGenerateColumns property to false and then creating a custom Columns collection. In addition to bound column fields, you can also display a button column field, a check box column field, a command field, a hyperlink column field, an image field, or a column field based on your own custom-defined template.

You can also combine explicitly declared column fields with automatically generated column fields. When both are used, explicitly declared column fields are rendered first, followed by the automatically generated column fields. Automatically generated bound column fields are not added to the GridView.Columns collection. For more information, see GridView.Columns.

If you set this property to true and set the DataBoundControl.ItemType property to a model type, System.Web.DynamicData.DynamicField controls are generated. If you do not set the DataBoundControl.ItemType property, System.Web.UI.WebControls.BoundField controls are generated. If you do not want System.Web.DynamicData.DynamicField controls, you have the following options:

Requirements

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