Like Search

2 posts, 0 answers
  1. Punit
    Punit avatar
    12 posts
    Member since:
    Sep 2008

    Posted 26 Dec 2008 Link to this post

    Posted on Dec 3 (permalink)


    We are implemting grid filtering by giving filter expression in Need_DataSource event by setting following property -


    which is set to something like the following

    DataSourceProperty.ToString().ToUpper().StartsWith("Hi")  where DataSourceProperty is a property of object, collection of which is set as Data Source to the grid just after setting filter expressio.

    Now my problem is that we wnat to give a user option to put % in the filter values and the filter should work like "Like" opertor in Oracle. So the input may be "punit%was%" .

    For this I have tried to set the property like below as suggested in documenattion at some place :-
    RadGrid1.MasterTableView.FilterExpression =
    "([Country] LIKE \'%Germany%\') ";
    Along with this I have also set  grid LINQ expressions to false (EnableLinqExpressions=false) .

    But this is not actually filtering the results and is just returning the results without filtering.


  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 28 Dec 2008 Link to this post

    Hi Punit,

    I am able to successfully filter the contents of the RadGrid using the FilterExpression property demonstrated in this demo. Here is a simple example I created using the Northwind database:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Telerik.Examples._Default" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
    <html xmlns="" > 
    <head runat="server"
        <form id="form1" runat="server"
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                    <telerik:AjaxSetting AjaxControlID="RadGrid1"
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1"  
                                LoadingPanelID="RadAjaxLoadingPanel1" /> 
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
                <img alt="Loading..."  
                    src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.LoadingProgressBar.gif") %>' 
                    style="margin-top: 100px;" /> 
            <telerik:RadGrid ID="RadGrid1" runat="server" 
                <MasterTableView FilterExpression="([ProductName] LIKE '%Anton%')"
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
                ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"  
                SelectCommand="SELECT * FROM [Products]"

    I hope this helps. If you continue to have trouble let me know and I'd be glad to help you further.

    Kevin Babcock
Back to Top