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
14Tofu  40 - 100 g pkgs.23.2535  
15Genen Shouyu6224 - 250 ml bottles15.503905
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
24Guaraná Fantástica10112 - 355 ml cans4.502000
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='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