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.v22.1.dll


public bool AutoGenerateColumns { get; set; }

Property Value

Type Default Description


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 the ASPxGridView. By default, this property is set to true. This forces the ASPxGridView 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 by setting the AutoGenerateColumns property to false. In this case, you should manually add columns to the ASPxGridView.Columns collection.


When the AutoGenerateColumns property is set to true, the only way to add a column to ASPxGridView is to handle the ASPxGridView.DataBound event. To avoid creating duplicate columns, it is necessary to add a condition that will check whether a column already exists.

View Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>How to add a column if the AutoGenerateColumns property is set to true</title>
    <form id="form1" runat="server">
        <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="True" DataSourceID="ds"
            KeyFieldName="CategoryID" ondatabound="ASPxGridView1_DataBound">
        <asp:AccessDataSource ID="ds" runat="server" DataFile="~/App_Data/nwind.mdb" SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
See Also