Adding template to FilterTemplate Programmatically

6 posts, 0 answers
  1. Ricky
    Ricky avatar
    3 posts
    Member since:
    Jan 2015

    Posted 14 Jan 2015 Link to this post

    Hello Anyone,
    I guess i am missing something here. I have created an ITemplate as below and adding it to the FilterTemplate of one of the column of RadGrid. 

    public class cblItemTemplate : ITemplate
        /// <summary>
        /// Create the template
        /// </summary>
        /// <param name="container"></param>
        public void InstantiateIn(Control container)
            Panel pnl = new Panel();
            CheckBoxList cbl = new CheckBoxList();
            cbl.ID = "cblCounty";
            cbl.AutoPostBack = false;
            cbl.DataBinding += cbl_DataBinding;
            Button btn = new Button();
            btn.ID = "btnApply";
            btn.Text = "Apply";
            Button btnClear = new Button();
            btnClear.ID = "btnClear";
            btnClear.Text = "Clear";
        void cbl_DataBinding(object sender, EventArgs e)
            CheckBoxList cbl = (CheckBoxList)sender;
            cbl.Items.Add(new ListItem("County1"));
            cbl.Items.Add(new ListItem("County2"));

    On first load, i see the template added to the column. But when i click on the Apply button, the template vanishes; i do not see it. I am adding the template on the ColumnCreated event of the radgrid as below:

    protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
         if (col.UniqueName == "county")
               var cbl = new cblItemTemplate();
               col.FilterTemplate = cbl;

    Can someone please let me know where i am going wrong? Do i need to add the filtertemplate in a different event?
  2. Ricky
    Ricky avatar
    3 posts
    Member since:
    Jan 2015

    Posted 14 Jan 2015 Link to this post

    I guess i also need to know how do i bind an event to button where i can rebind the grid with the FilterExpression. Any help is much appreciated!
  3. Ricky
    Ricky avatar
    3 posts
    Member since:
    Jan 2015

    Posted 16 Jan 2015 Link to this post

    Telerik team? No response?
  4. Eyup
    Eyup avatar
    3916 posts

    Posted 19 Jan 2015 Link to this post

    Hello Ricky,

    I've created a sample RadGrid web site to demonstrate how you can modify the filter cell of a given column programmatically. This is the recommended way instead of creating dynamic FilterTemplate. Please run the attached application and let me know if it helps you.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  5. Kiran
    Kiran  avatar
    53 posts
    Member since:
    Oct 2018

    Posted 12 Nov 2019 in reply to Eyup Link to this post

    Hi Eyup,

    Can you please provide a VB version of the attachment? I tried converting but somethings not right. 

    Thank you.

  6. Rumen
    Rumen avatar
    14216 posts

    Posted 13 Nov 2019 Link to this post

    Hi Kiran,

    Please find attached the requested VB version of the example! Please give it a spin and let me know how it works on your side.

    Best Regards,
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top