ASPxGridView Class
A server ASPxGridView control.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v18.2.dll
Declaration
Related API Members
The following members return ASPxGridView objects:
Library | Related API Members |
---|---|
eXpressApp Framework | ASPxGridListEditor.Grid |
ASPxGridViewCustomButtonInitializer.Grid | |
ASP.NET Web Forms Controls | ASPxGridLookup.GridView |
ASPxGridViewExporter.GridView | |
FileManagerDetailsViewItemTemplateContainer.Grid | |
GridViewBaseTemplateContainer.Grid | |
GridViewColumn.Grid | |
GridViewColumnCollection.Grid |
Remarks
The ASPxGridView is a data bound control that provides a two-dimensional representation of data from a data source in grid format. Data source fields and records are presented as columns and rows in a table.
Note
Refer to the Main Features topic to get a list of the main grid features.
Columns
The ASPxGridView control stores its columns in the ASPxGridView.Columns collection.
You can create data columns automatically for each field in the data source when the ASPxGridView is rendered or manually based on the ASPxGridView.AutoGenerateColumns property value. The order of columns is the same as the order of fields in the data source. Set the ASPxGridView.AutoGenerateColumns property to false to manually control which columns appear in the ASPxGridView. In this case, you should add data columns to the ASPxGridView.Columns collection.
Client-Side API
The ASPxGridView control provides you with comprehensive client-side functionality, implemented using JavaScript code.
- Client Object - The control’s client-side equivalent is represented by the ASPxClientGridView object.
- Accessing Client Object - On the client side, the client object can be accessed directly by the name specified using the ASPxGridBase.ClientInstanceName property.
- Client Events - The available client events can be accessed by using the ASPxGridView.ClientSideEvents property.
The client-side API is always available for this control.
Online Demos
Example
This example demonstrates how to create and initialize ASPxGridView at design time and runtime.
Declarative approach:
<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>
Programmatic approach:
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);
}
Result: