ASPX Page
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%
@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title></title>
</
head>
<
body>
<form id="form1" runat="server">
<asp:ScriptManager ID="aspScript" runat="server">
</asp:ScriptManager>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [UnitsInStock], [UnitPrice] FROM [Products]">
</asp:SqlDataSource>
<telerik:RadGrid ID="grdTemplate" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="true" ShowGroupPanel="True" Skin="Office2007" Height="500" Width="100%"
OnColumnCreated="grdTemplate_ColumnCreated">
<ClientSettings AllowColumnsReorder="False" AllowDragToGroup="True">
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView AutoGenerateColumns="true" TableLayout="Fixed" ShowFooter="true" ShowGroupFooter="true" />
</telerik:RadGrid>
</form>
</
body>
</
html>
Code Behind
using
System;
using
System.Collections.Generic;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
public
partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Add the expression
grdTemplate.MasterTableView.GroupByExpressions.Add(
GridGroupByExpression.Parse("SupplierID Group By SupplierID"));
}
protected void grdTemplate_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
// Determine the column type
if (e.Column is GridBoundColumn && e.Column.UniqueName == "UnitPrice")
{
// Set the column aggreagate
(e.Column
as GridBoundColumn).Aggregate = GridAggregateFunction.Sum;
}
}
}