This walkthrough shows you how to display GroupTotal of ChildTable.
During this walkthrough, you will learn how to do the following :
- Bind WebGrid to Hierarchical mode.
- GroupTotal of Quantity from Order Details in InitializeLayout.
Prerequisites
In order to complete this walkthrough, you will need the following:
- Access to the Microsoft Access Northwind database.
- Visual Studio 2005 Application.
Step-By-Step Instructions
- Bind WebGrid to Hierarchical mode.
- In the InitializeLayout event of the grid, expand the child rows.
C# Copy Code if(!IsPostBack) { // Prepare the Group Total WebGrid1.GetTableByName("Order Details").GroupTotalVisible = true; WebGrid1.GetTableByName("Order Details").Columns.GetNamedItem("Quantity").AggregateFunction = AggregateFunctions.Sum; WebGridGroup groupByProductID = new WebGridGroup(); groupByProductID.Name = "GroupByProductID"; groupByProductID.ColumnMember = "ProductID"; WebGrid1.GetTableByName("Order Details").GroupedColumns. Add(groupByProductID); }
- Finally, the WebForm will look like the following snapshot: