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

Custom Paging

Custom paging, grouping and filtering on 100000 items using NeedDataSource

Drag a column header and drop it here to group by that column
IDNameUnit PriceDateDiscontinued
Page size:
 100000 items in 10000 pages
0Côte de Blaye23.255/10/2007 12:00:00 AM
1Boston Crab Meat99/13/2008 12:00:00 AM
2Singaporean Hokkien Fried Mee45.62/22/2008 12:00:00 AM
3Gula Malacca321/2/2009 12:00:00 AM
4Boston Crab Meat99/13/2008 12:00:00 AM
5Spegesild195/12/2008 12:00:00 AM
6Côte de Blaye23.255/10/2007 12:00:00 AM
7Chocolade18.48/26/2008 12:00:00 AM
8Singaporean Hokkien Fried Mee45.62/22/2008 12:00:00 AM
9Valkoinen suklaa147/16/2007 12:00:00 AM
  • NoFilter
  • Contains
  • DoesNotContain
  • StartsWith
  • EndsWith
  • EqualTo
  • NotEqualTo
  • GreaterThan
  • LessThan
  • GreaterThanOrEqualTo
  • LessThanOrEqualTo
  • Between
  • NotBetween
  • IsEmpty
  • NotIsEmpty
  • IsNull
  • NotIsNull
  • Custom


Custom paging, grouping and filtering on 100000 items using ObjectDataSource

Drag a column header and drop it here to group by that column
IDNameUnit PriceDateDiscontinued
Page size:
 100000 items in 10000 pages
0Côte de Blaye23.255/10/2007 12:00:00 AM
1Boston Crab Meat99/13/2008 12:00:00 AM
2Singaporean Hokkien Fried Mee45.62/22/2008 12:00:00 AM
3Gula Malacca321/2/2009 12:00:00 AM
4Boston Crab Meat99/13/2008 12:00:00 AM
5Spegesild195/12/2008 12:00:00 AM
6Côte de Blaye23.255/10/2007 12:00:00 AM
7Chocolade18.48/26/2008 12:00:00 AM
8Singaporean Hokkien Fried Mee45.62/22/2008 12:00:00 AM
9Valkoinen suklaa147/16/2007 12:00:00 AM
  • NoFilter
  • Contains
  • DoesNotContain
  • StartsWith
  • EndsWith
  • EqualTo
  • NotEqualTo
  • GreaterThan
  • LessThan
  • GreaterThanOrEqualTo
  • LessThanOrEqualTo
  • Between
  • NotBetween
  • IsEmpty
  • NotIsEmpty
  • IsNull
  • NotIsNull
  • Custom
There are cases in which you may want to fetch only a fixed number of records and perform operations over this specified set of data. Telerik RadGrid allows such data manipulation through the custom paging mechanism integrated in the control. The main steps you need to undertake are:
  • Set AllowPaging = true and AllowCustomPaging = true for your grid instance
  • Implement code logic which to extract merely a fixed number of records from the grid source and present them in the grid structure
  • The total number of records in the grid source should be defined through the VirtualItemCount property of the MasterTableView/GridTableView instance. Thus the grid "understands" that the data source contains the specified number of records and it should fetch merely part of them at a time to execute requested operation.
This example demonstrates the approach for custom paging depicted above. The simulated "DataLayer" wraps the logic for extracting records only for the specified page (along with deleting records option). Telerik RadGrid maintains the pager buttons, changing of pager and other presentation specific features.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
    • DefaultCS.aspx.cs
    • MyBusinessObjects.cs
<%@ Page Language="c#" Inherits="Telerik.GridExamplesCSharp.Programming.CustomPaging.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<%@ 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" />
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <div class="demo-container no-bg">
        <h2>Custom paging, grouping and filtering on 100000 items using NeedDataSource</h2>
        <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" ShowGroupPanel="true" AllowFilteringByColumn="true"
                ShowStatusBar="true" runat="server" AllowPaging="True" AllowSorting="true"
                AllowCustomPaging="True" VirtualItemCount="100000" OnNeedDataSource="RadGrid1_NeedDataSource"
                OnGroupsChanging="RadGrid1_GroupsChanging" OnColumnCreated="RadGrid_ColumnCreated">
                <ClientSettings AllowDragToGroup="true">
                </ClientSettings>
                <MasterTableView TableLayout="Fixed"></MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
        <br />
        <br />
        <h2>Custom paging, grouping and filtering on 100000 items using ObjectDataSource</h2>
        <telerik:RadAjaxPanel runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid2" runat="server" AllowSorting="true" DataSourceID="ObjectDataSource1"
                ShowGroupPanel="true" AllowFilteringByColumn="true" ShowStatusBar="true"
                AllowPaging="True" OnColumnCreated="RadGrid_ColumnCreated">
                <ClientSettings AllowDragToGroup="true">
                </ClientSettings>
                <MasterTableView OverrideDataSourceControlSorting="true" TableLayout="Fixed">
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
    </div>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnablePaging="true" SelectCountMethod="SelectCount"
        SelectMethod="Select" TypeName="Telerik.Web.Examples.Grid.MyBusinessObjectCollection"></asp:ObjectDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance