PersistenceFramework - 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
1Chai1110 boxes x 20 bags18.0039010
2Chang1124 - 12 oz bottles19.00174025
3Aniseed Syrup1212 - 550 ml bottles10.00137025
4Chef Anton's Cajun Seasoning2248 - 6 oz jars22.005300
5Chef Anton's Gumbo Mix2236 boxes21.35000
6Grandma's Boysenberry Spread3212 - 8 oz jars25.00120025
7Uncle Bob's Organic Dried Pears3712 - 1 lb pkgs.30.0015010
8Northwoods Cranberry Sauce3212 - 12 oz jars40.00600
9Mishi Kobe Niku4618 - 500 g pkgs.97.002900
10Ikura4812 - 200 ml jars31.003100
Page size:
 77 items in 8 pages
  • NoFilter
  • Contains
  • DoesNotContain
  • StartsWith
  • EndsWith
  • EqualTo
  • NotEqualTo
  • GreaterThan
  • LessThan
  • GreaterThanOrEqualTo
  • LessThanOrEqualTo
  • Between
  • NotBetween
  • IsEmpty
  • NotIsEmpty
  • IsNull
  • NotIsNull
  • Custom
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

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 PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <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">
        <PersistenceSettings>
            <telerik:PersistenceSetting ControlID="RadGrid1" />
        </PersistenceSettings>
    </telerik:RadPersistenceManager>
    <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.
    </qsf:MessageBox>
    <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>
            <telerik:RadButton RenderMode="Lightweight" ID="LoadButton" Text="Load State" runat="server" OnClick="LoadButton_Click">
                <Icon PrimaryIconUrl="../../Images/load.png"></Icon>
            </telerik:RadButton>
            <telerik:RadButton RenderMode="Lightweight" ID="ResetButton" Text="Reset Stored State" runat="server" OnClick="ResetButton_Click">
                <Icon PrimaryIconUrl="../../Images/reset.png"></Icon>
            </telerik:RadButton>
        </div>
        <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">
                </MasterTableView>
                <ClientSettings AllowDragToGroup="true">
                    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                </ClientSettings>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
    </div>
    <asp:EntityDataSource runat="server" ID="EntityDataSource1" ConnectionString="name=NorthwindReadOnlyEntities"
        DefaultContainerName="NorthwindReadOnlyEntities" OrderBy="it.[ProductID]" EntitySetName="Products">
    </asp:EntityDataSource>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance

Help Us Improve

Was this example helpful?