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
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

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.

  • DefaultVB.aspx
  • CookieStorageProviderVB.vb
    • CookieStorageProviderVB.vb
    • DefaultVB.aspx.vb
  • styles.css
<%@ Page Title="" Language="VB"  AutoEventWireup="false"
    CodeFile="DefaultVB.aspx.vb" Inherits="PersistenceFramework_Examples_CustomStorageProvider_DefaultVB" %>

<%@ 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