Adding a Filter expression on page load and pre-populating it

2 posts, 1 answers
  1. Richard
    Richard avatar
    63 posts
    Member since:
    Apr 2008

    Posted 19 May 2010 Link to this post

    Is there a way to create a series of Filter expression items, pre-populate them and display them when the grid is first loaded?

    I saw another post that showed this example, but I cannot get it to display.


    RadFilterTextFieldEditor editor = new RadFilterTextFieldEditor();




    if (!IsPostBack)



    editor.FieldName =



    editor.DataType =




  2. Answer
    Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 20 May 2010 Link to this post

    Hi Richard,

    Indeed the preceding code will add FieldEditor to the RadFilter control so that the field appears in the added expressions field name drop down.
    However if you want to add a default filter expression, you can try extending the code as below:

    protected void Page_Load(object sender, EventArgs e)
        RadFilterTextFieldEditor editor = new RadFilterTextFieldEditor();
        if (!IsPostBack)
            editor.FieldName = "ContactTitle";
            editor.DataType = typeof(string);
            RadFilterEqualToFilterExpression<string> expr = new RadFilterEqualToFilterExpression<string>("ContactTitle");           
            expr.Value = "Sales Representative";

    For your convenience I am attaching a runnable sample illustrating the suggested approach.

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top