Gets or sets a value indicating whether bound fields are automatically created for each field in the data source.
Assembly: System.Web (in System.Web.dll)
abstract AutoGenerateColumns : bool with get, set override AutoGenerateColumns : bool with get, set
Property ValueType: System.Boolean
true to automatically create bound fields for each field in the data source; otherwise, false. The default is true.
When the property is set to true, an AutoGeneratedField object is automatically created for each field in the data source. Each field is then displayed as a column in the 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 GridView control automatically generate the column fields, you can manually define the column fields by setting the 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 Columns collection. For more information, see Columns.
If you set this property to true and set the ItemType property to a model type, DynamicField controls are generated. If you do not set the ItemType property, BoundField controls are generated. If you do not want DynamicField controls, you have the following options:
Write custom code to automatically generate fields by creating and assigning your own ColumnsGenerator class and assigning an instance of it to the control.
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.