Filter - Save/Load RadFilter expressions

  • And
  • Or
  • Not And
  • Not Or
  • Contains
  • DoesNotContain
  • StartsWith
  • EndsWith
  • EqualTo
  • NotEqualTo
  • GreaterThan
  • LessThan
  • GreaterThanOrEqualTo
  • LessThanOrEqualTo
  • Between
  • NotBetween
  • IsEmpty
  • NotIsEmpty
  • IsNull
  • NotIsNull
  • OrderID
  • OrderDate
  • ShipCity
  • ShipCountry
  • ShipName

OrderIDOrderDateShipCityShipCountryShipName
Page size:
 830 items in 83 pages
102487/4/1996 12:00:00 AMReimsFranceVins et alcools Chevalier
102497/5/1996 12:00:00 AMMünsterGermanyToms Spezialitäten
102507/8/1996 12:00:00 AMRio de JaneiroBrazilHanari Carnes
102517/8/1996 12:00:00 AMLyonFranceVictuailles en stock
102527/9/1996 12:00:00 AMCharleroiBelgiumSuprêmes délices
102537/10/1996 12:00:00 AMRio de JaneiroBrazilHanari Carnes
102547/11/1996 12:00:00 AMBernSwitzerlandChop-suey Chinese
102557/12/1996 12:00:00 AMGenèveSwitzerlandRichter Supermarkt
102567/15/1996 12:00:00 AMResendeBrazilWellington Importadora
102577/16/1996 12:00:00 AMSan CristóbalVenezuelaHILARION-Abastos
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

This example demonstrates how to save/load RadFilter expressions by user. RadFilter public API offers two methods to achieve this functionality:

  • SaveSettings: Serialize the control expressions to Base64 encoded string.
  • LoadSettings: Loads the provided state in the control. The parameter for this method must be Base64 encoded string representing saved control expressions.
  • Load last settings on initial load: Loads the last set settings if you navigate away from the page and the come back.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.FilterExamplesCSharp.SaveLoadExpressions.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>
    <style type="text/css">
        div.container
        {
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="CheckBoxes" />
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="LoadingPanel1" CssClass="demo-container">
        <div class="container">
            <telerik:RadPushButton Text="Save Settings" runat="server" ID="SaveSettings" OnClick="SaveSettings_Clicked"></telerik:RadPushButton>
            <telerik:RadPushButton Text="Load Settings" runat="server" ID="LoadSettings" OnClick="LoadSettings_Clicked"></telerik:RadPushButton>
            <asp:CheckBox runat="server" ID="CheckBox1" AutoPostBack="true" Text="Load last settings on initial load" />
        </div>
        <telerik:RadFilter RenderMode="Lightweight" runat="server" ID="RadFilter1" FilterContainerID="RadGrid1">
        </telerik:RadFilter>
        <br />
        <telerik:RadGrid RenderMode="Lightweight" runat="server" ID="RadGrid1" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" DataSourceID="SqlDataSource1">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" DataType="System.Int32">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="OrderDate">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="ShipCountry">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    <telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1">
    </telerik:RadAjaxLoadingPanel>
    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select OrderID, OrderDate, ShipVia, ShipName, ShipAddress, ShipCity, ShipCountry FROM Orders"></asp:SqlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance

Help Us Improve

Was this example helpful?