Skip to main content

ASPxGridView.DataColumns Property

Gets the collection of all data columns within the ASPxGridView control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web


public ReadOnlyGridColumnCollection<GridViewDataColumn> DataColumns { get; }

Property Value

Type Description

A collection of data columns in an ASPxGridView.


The DataColumns property provides access to a collection that contains data columns of the ASPxGridView control. This collection is read-only, since individual columns can be manipulated (added or removed) at the level of a grid control (ASPxGridView.Columns). The collection obtained via the DataColumns property allows you to easily iterate through data grid columns and access any required column identified by its name, field name, or caption.


In some cases, when the default filter row editor’s functionality is not enough, you can provide custom filter cell content using the GridViewColumn.FilterTemplate.

In this example, a default cell editor is replaced with the ASPxGridLookup control. The control’s ASPxClientEdit.ValueChanged client-side event is used to send a callback to the server side, invoking the grid’s ASPxGridView.CustomCallback event. In the event handler, a filter criteria is created and applied to the grid using the ASPxGridView.ApplyFilterToColumn method.

View Example

<head runat="server">
    <script type="text/javascript">
        function Lookup_ValueChanged(s, e) {
    <form id="form1" runat="server">
        <div style="max-width: 960px">
        <dx:ASPxGridView runat="server" ID="Grid" AutoGenerateColumns="False" DataSourceID="ProductsDataSource"
            ClientInstanceName="grid" OnCustomCallback="Grid_CustomCallback" EnableViewState="false">
                <dx:GridViewDataTextColumn FieldName="CategoryName">
                        <dx:ASPxGridLookup runat="server" ID="Lookup" AutoGenerateColumns="False" DataSourceID="CategoriesDataSource"
                            KeyFieldName="CategoryID" SelectionMode="Multiple" TextFormatString="{0}">
                                <dx:GridViewCommandColumn ShowSelectCheckbox="true" />
                                <dx:GridViewDataTextColumn FieldName="CategoryName" />
                                <dx:GridViewDataBinaryImageColumn FieldName="Picture">
                                    <PropertiesBinaryImage ImageWidth="48" />
                            <ClientSideEvents ValueChanged="Lookup_ValueChanged" />
                <dx:GridViewDataTextColumn FieldName="ProductName" />
                <dx:GridViewDataTextColumn FieldName="ProductSales" />
                <dx:GridViewDataDateColumn FieldName="ShippedDate" />
            <Settings ShowFilterRow="true" />
        <asp:AccessDataSource ID="ProductsDataSource" runat="server" DataFile="~/App_Data/nwind.mdb"
            SelectCommand="SELECT * FROM [ProductReports]" />
        <asp:AccessDataSource ID="CategoriesDataSource" runat="server" DataFile="~/App_Data/nwind.mdb"
            SelectCommand="SELECT * FROM [Categories]" />
using DevExpress.Data.Filtering;
using DevExpress.Web;

public partial class _Default : System.Web.UI.Page {
    protected void Grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {
        if(e.Parameters == "FilterByCategories") {
            var column = Grid.DataColumns["CategoryName"];
            var lookup = Grid.FindFilterCellTemplateControl(column, "Lookup") as ASPxGridLookup;
            if(lookup != null)
                Grid.ApplyFilterToColumn(column, CreateCriteria(lookup, column.FieldName));

    protected CriteriaOperator CreateCriteria(ASPxGridLookup gridLookup, string fieldName) {
        var values = gridLookup.GridView.GetSelectedFieldValues(fieldName);
        return values.Count > 0 ? new InOperator(fieldName, values) : null;
See Also