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

Custom Storage Provider

The Save/Load buttons will persist/load the state of the control. The Reset button will remove the cookie used as a settings storage.
Drag a column header and drop it here to group by that column
14Tofu6740 - 100 g pkgs.23.253500
15Genen Shouyu6224 - 250 ml bottles15.503905
16Pavlova7332 - 500 g boxes17.4529010
17Alice Mutton7620 - 1 kg tins39.00000
18Carnarvon Tigers7816 kg pkg.62.504200
19Teatime Chocolate Biscuits8310 boxes x 12 pieces9.202505
20Sir Rodney's Marmalade8330 gift boxes81.004000
21Sir Rodney's Scones8324 pkgs. x 4 pieces10.003405
22Gustaf's Knäckebröd9524 - 500 g pkgs.21.00104025
23Tunnbröd9512 - 250 g pkgs.9.0061025
Page size:
 65 items in 7 pages
  • NoFilter
  • Contains
  • DoesNotContain
  • StartsWith
  • EndsWith
  • EqualTo
  • NotEqualTo
  • GreaterThan
  • LessThan
  • GreaterThanOrEqualTo
  • LessThanOrEqualTo
  • Between
  • NotBetween
  • IsEmpty
  • NotIsEmpty
  • IsNull
  • NotIsNull
  • Custom

In this example you can see how to preserve the state of RadGrid using a custom storage provider. For the purpose of this demo we have created a simple CookieStorageProvider that uses GZip compression to reduce the size of the settings before saving them in a cookie (with Base64 encoding). Put simply, the custom provider has a SaveStateToStorage and LoadStateFromStorage methods which are used by the PersistenceManager to load/save the state.
RadGrid settings persisted by the PersistenceManager include Sorting, Filtering, Grouping, Edit/Insert Indexes, and Paging.
Please use the Save/Load/Reset buttons to test the functionality demonstrated by this example.

  • DefaultCS.aspx
  • CookieStorageProviderCS.cs
    • CookieStorageProviderCS.cs
    • DefaultCS.aspx.cs
  • styles.css
<%@ Page Title="" Language="C#"  AutoEventWireup="true" 
    CodeFile="DefaultCS.aspx.cs" Inherits="PersistenceFramework_Examples_CustomStorageProvider_DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadPersistenceManager ID="RadPersistenceManager1" runat="server">
            <telerik:PersistenceSetting ControlID="RadGrid1" />
    <qsf:MessageBox ID="InformationBox1" runat="server" Type="Info" Icon="Info"> 
        The <em>Save/Load</em> buttons will
        persist/load the state of the control. The <em>Reset</em> button will remove the cookie used as a settings storage.
    <div class="demo-container no-bg">
        <div class="demo-settings">
            <telerik:RadButton RenderMode="Lightweight" ID="SaveButton" Text="Save State" runat="server" OnClick="SaveButton_Click">
                <Icon PrimaryIconUrl="../../Images/save.png"></Icon>
            <telerik:RadButton RenderMode="Lightweight" ID="LoadButton" Text="Load State" runat="server" OnClick="LoadButton_Click">
                <Icon PrimaryIconUrl="../../Images/load.png"></Icon>
            <telerik:RadButton RenderMode="Lightweight" ID="ResetButton" Text="Reset Stored State" runat="server" OnClick="ResetButton_Click">
                <Icon PrimaryIconUrl="../../Images/reset.png"></Icon>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" DataSourceID="EntityDataSource1" AllowSorting="true"
                ShowGroupPanel="true" AllowPaging="true" AllowFilteringByColumn="true"
                OnColumnCreated="RadGrid1_ColumnCreated" AutoGenerateEditColumn="true">
                <MasterTableView CommandItemDisplay="Top" HeaderStyle-Width="160px">
                <ClientSettings AllowDragToGroup="true">
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    <asp:EntityDataSource runat="server" ID="EntityDataSource1" ConnectionString="name=NorthwindReadOnlyEntities"
        DefaultContainerName="NorthwindReadOnlyEntities" OrderBy="it.[ProductID]" EntitySetName="Products">
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">

Support & Learning Resources

Find Assistance