Skip to main content

ASPxGridView.AutoGenerateColumns Property

Gets or sets whether columns are automatically created for all fields in the underlying data source.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web


public bool AutoGenerateColumns { get; set; }

Property Value

Type Default Description
Boolean true

true to automatically create columns for all fields in the underlying data source; otherwise, false.


The AutoGenerateColumns property specifies which data fields are rendered by ASPxGridView. By default, this property is set to true. This forces the grid to render each field from the data source as a column. The order of columns is the same as the order of fields in the data source.

You can also manually control which columns are to appear in the ASPxGridView control by setting the AutoGenerateColumns property to false. In this case, you should manually add columns to the ASPxGridView.Columns collection.


The following example demonstrates how to add a column to the grid when the AutoGenerateColumns property is enabled.

View Example: How to add a column if the AutoGenerateColumns property is set to true

<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="True" DataSourceID="ds"
    KeyFieldName="CategoryID" ondatabound="ASPxGridView1_DataBound">
protected void ASPxGridView1_DataBound (object sender, EventArgs e) {
    ASPxGridView grid = sender as ASPxGridView;
    if (grid.Columns.IndexOf(grid.Columns["CommandColumn"]) != -1)
    GridViewCommandColumn col = new GridViewCommandColumn();
    col.Name = "CommandColumn";
    // ...
    // ...

The following code snippets (auto-collected from DevExpress Examples) contain references to the AutoGenerateColumns property.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also