Tab
A newer version of this page is available. Switch to the current version.

ASPxGridView Class

A grid control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public class ASPxGridView :
    ASPxGridBase,
    ISummaryItemsOwner

The following members accept/return ASPxGridView objects:

Library Related API Members
ASP.NET Controls and MVC Extensions ASPxGridLookup.GridView
ASPxGridViewExporter.GridView
FileManagerDetailsViewItemTemplateContainer.Grid
GridViewBaseTemplateContainer.Grid
GridViewColumn.Grid
GridViewColumnCollection.Grid
eXpressApp Framework ASPxGridListEditor.Grid
ASPxGridViewCustomButtonInitializer.Grid

Remarks

The ASPxGridView is a data bound control that displays data from a data source in grid format. The grid displays data source fields and records as columns and rows in a table.

ASPxGridView_Class

Create a Grid View

Design Time

The ASPxGridView control is available on the DX.19.1: Data & Analytics toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize control settings, or paste the control markup in the page’s source code.

<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
    KeyFieldName="ProductID" Theme="MaterialCompact">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="2">
        </dx:GridViewDataTextColumn>
    </Columns>
</dx:ASPxGridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb;
    Persist Security Info=True" ProviderName="System.Data.OleDb" 
    SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock] FROM [Products]">
</asp:SqlDataSource>

Run Time

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb;
    Persist Security Info=True" ProviderName="System.Data.OleDb" 
    SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock] FROM [Products]">
</asp:SqlDataSource>
using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)  {
     ASPxGridView grid1 = new ASPxGridView();
     grid1.ID = "grid1";
     grid1.AutoGenerateColumns = false;
     grid1.DataSourceID = "SqlDataSource1";
     grid1.KeyFieldName = "ProductID";
     grid1.Columns.AddRange(new GridViewDataColumn[]{
          new GridViewDataColumn { FieldName="ProductID", ReadOnly = true, VisibleIndex = 0},
          new GridViewDataColumn() { FieldName = "ProductName", VisibleIndex = 1 },
          new GridViewDataColumn() { FieldName = "UnitPrice", VisibleIndex = 2 },
     });
     Page.Form.Controls.Add(grid1);
}