GridViewColumn.Columns Property
Provides access to a collection of columns that the current column combines.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
GridViewColumnCollection | An GridViewColumnCollection object that is a collection of columns grouped by the current column. |
Remarks
The Columns property stores a collection of GridViewColumn objects which can be data columns, combined by the current column. The obtained column collection provides methods that allow you to add new and remove existing columns. Individual columns can be accessed using indexed notation.
Example
This example illustrates how to organize ASPxGridView columns and data cells into logical groups (bands) and display them using multi-row representation. Bands can be created by columns of the GridViewBandColumn type (header bands) or by using data columns bound to the grid (data cell bands). Header bands are used to organize columns into logical groups. They do not have associated data cells and are displayed only as a top-level header of the grid. Data cell bands are organized by using grid columns bound to data source fields. They contain data values displayed in the grid. Data cell bands allow you to create a structure according to which associated data cells will be displayed within grid rows. See also: ASPxGridView - Data Cell Bands online demo
ASPxGridView - Header Bands online demo
Note
A complete sample project is available at https://github.com/DevExpress-Examples/aspxgridview-how-to-create-header-and-data-cell-bands-t399420
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v16.1, Version=16.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagprefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="800px" Theme="Office2003Blue">
<Columns>
<dx:GridViewBandColumn Caption="Employee Information" VisibleIndex="10">
<HeaderStyle HorizontalAlign="Center" />
<Columns>
<dx:GridViewDataTextColumn FieldName="Title" VisibleIndex="0">
<HeaderStyle HorizontalAlign="Center" />
<Columns>
<dx:GridViewDataTextColumn FieldName="LastName" VisibleIndex="0">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="FirstName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataDateColumn FieldName="BirthDate" VisibleIndex="2">
</dx:GridViewDataDateColumn>
</Columns>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Address" VisibleIndex="1">
<HeaderStyle HorizontalAlign="Center" />
<Columns>
<dx:GridViewDataTextColumn FieldName="City" VisibleIndex="0">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="PostalCode" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Country" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="HomePhone" VisibleIndex="3">
</dx:GridViewDataTextColumn>
</Columns>
</dx:GridViewDataTextColumn>
<dx:GridViewDataDateColumn FieldName="HireDate" VisibleIndex="2">
<HeaderStyle HorizontalAlign="Center" />
</dx:GridViewDataDateColumn>
</Columns>
</dx:GridViewBandColumn>
</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 [LastName], [FirstName], [Title], [BirthDate], [HireDate], [Address], [City], [PostalCode], [Country], [HomePhone] FROM [Employees]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Columns property.
Note
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.