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
11Queso Cabrales541 kg pkg.21.00223030
12Queso Manchego La Pastora5410 - 500 g pkgs.38.008600
13Konbu682 kg box6.002405
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
Page size:
 68 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='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