New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Advanced Data Binding

empty
ProfitCountryCity
TransportTypeCompany
empty
BulgariaBulgaria Total FranceFrance Total GreeceGreece Total HungaryHungary Total ItalyItaly Total RomaniaRomania Total SpainSpain Total UKUK TotalGrand Total
SofiaParisAthensKavalaSzegedBresciaArgesBucharestMadridBrandon
empty
MicrovanAdvanced Services Ace
Continential World Corp
Digital Corporate
Executive Imagination
Interactive Key Software
Internet Innovation Telecom
Networks Future Ll
Profit Interworks
Server Compu
Superior Outsourcing LLC
Grand Total
empty
$59,450.00$59,450.00$127,817.50$127,817.50$133,762.50$53,505.00$187,267.50$44,587.50$44,587.50$29,725.00$29,725.00$59,450.00$65,395.00$124,845.00$62,422.50$62,422.50$53,505.00$53,505.00$689,620.00
$65,395.00$65,395.00$154,570.00$154,570.00$101,065.00$62,422.50$163,487.50$65,395.00$65,395.00$32,697.50$32,697.50$44,587.50$47,560.00$92,147.50$65,395.00$65,395.00$32,697.50$32,697.50$671,785.00
$59,450.00$59,450.00$133,762.50$133,762.50$121,872.50$50,532.50$172,405.00$62,422.50$62,422.50$26,752.50$26,752.50$74,312.50$44,587.50$118,900.00$71,340.00$71,340.00$65,395.00$65,395.00$710,427.50
$59,450.00$59,450.00$104,037.50$104,037.50$95,120.00$62,422.50$157,542.50$56,477.50$56,477.50$56,477.50$56,477.50$59,450.00$71,340.00$130,790.00$56,477.50$56,477.50$50,532.50$50,532.50$671,785.00
$53,505.00$53,505.00$127,817.50$127,817.50$109,982.50$68,367.50$178,350.00$71,340.00$71,340.00$47,560.00$47,560.00$65,395.00$59,450.00$124,845.00$38,642.50$38,642.50$83,230.00$83,230.00$725,290.00
$68,367.50$68,367.50$104,037.50$104,037.50$118,900.00$62,422.50$181,322.50$50,532.50$50,532.50$89,175.00$89,175.00$50,532.50$53,505.00$104,037.50$59,450.00$59,450.00$44,587.50$44,587.50$701,510.00
$41,615.00$41,615.00$107,010.00$107,010.00$109,982.50$62,422.50$172,405.00$65,395.00$65,395.00$53,505.00$53,505.00$50,532.50$47,560.00$98,092.50$53,505.00$53,505.00$26,752.50$26,752.50$618,280.00
$35,670.00$35,670.00$86,202.50$86,202.50$92,147.50$38,642.50$130,790.00$62,422.50$62,422.50$56,477.50$56,477.50$62,422.50$29,725.00$92,147.50$65,395.00$65,395.00$71,340.00$71,340.00$600,445.00
$68,367.50$68,367.50$118,900.00$118,900.00$107,010.00$59,450.00$166,460.00$68,367.50$68,367.50$41,615.00$41,615.00$53,505.00$56,477.50$109,982.50$50,532.50$50,532.50$68,367.50$68,367.50$692,592.50
$59,450.00$59,450.00$107,010.00$107,010.00$104,037.50$53,505.00$157,542.50$50,532.50$50,532.50$65,395.00$65,395.00$50,532.50$38,642.50$89,175.00$50,532.50$50,532.50$56,477.50$56,477.50$636,115.00
$7,076,087.50$7,076,087.50$13,506,732.50$13,506,732.50$13,299,682.50$6,820,965.00$20,120,647.50$6,654,812.50$6,654,812.50$6,488,045.00$6,488,045.00$6,882,260.00$6,511,107.50$13,393,367.50$6,564,920.00$6,564,920.00$6,957,290.00$6,957,290.00$80,761,902.50
Page:
of 7Page size:
The key to the advanced data binding of Telerik's Pivot Table is handling correctly RadPivotGrid's NeedDataSource event. That's why we chose this exact name. 'Need' in this case actually means that if at an exact moment the data-source property does not point to a valid data-source object, the pivotgrid will not behave correctly.
The advantages of using this event are that the developer does not need to write any code handling the logic about when and how the data-binding should be processed. It is still the developer's responsibility to construct properly a data source object and assign it to the RadPivotGrid's DataSource property. In the code of the NeedDataSource handler you should prepare the data source (list of objects) for Telerik RadPivotGrid and assign it to the grid's DataSource property.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="c#" AutoEventWireup="false" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.PivotGrid.Examples.AdvancedDataBinding.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
<div class="demo-container no-bg">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadPivotGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadPivotGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadPivotGrid RenderMode="Lightweight" runat="server" ID="RadPivotGrid1" AllowPaging="true" Height="500px" OnNeedDataSource="RadPivotGrid1_NeedDataSource"
            AllowSorting="true" AllowFiltering="false" ShowFilterHeaderZone="false">
            <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true"></PagerStyle>
            <DataCellStyle Width="100px" />
            <Fields>
                <telerik:PivotGridRowField DataField="TransportType">
                </telerik:PivotGridRowField>
                <telerik:PivotGridRowField DataField="Company">
                </telerik:PivotGridRowField>
                <telerik:PivotGridColumnField DataField="Country">
                </telerik:PivotGridColumnField>
                <telerik:PivotGridColumnField DataField="City">
                </telerik:PivotGridColumnField>
                <telerik:PivotGridAggregateField DataField="Profit" Aggregate="Sum" DataFormatString="{0:C}">
                </telerik:PivotGridAggregateField>
                <telerik:PivotGridAggregateField IsHidden="true" DataField="Expenses" Aggregate="Sum">
                </telerik:PivotGridAggregateField>
            </Fields>
            <ClientSettings>
                <Scrolling AllowVerticalScroll="true"></Scrolling>
            </ClientSettings>
        </telerik:RadPivotGrid>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance