Handling Input Errors in Gridview Filter Row

2 posts, 0 answers
  1. Vahagn Hokhikyan
    Vahagn Hokhikyan avatar
    6 posts
    Member since:
    Feb 2005

    Posted 17 Dec 2009 Link to this post

    I have a gridview (v2.0.50727) with filter row enabled. Some of the gridview columns have integer datatype. When a string is entered instead of integer an exception is being thrown for understandable reason. My question is where do I handle the input validation? (What event do I subscribe, etc).

    Also is it possible to have a dropdown list in the filter row for some of the columns? One of the columns in my grid is a foreign key column and is being populated with string representation of the value. Please refer to an example if possible. I have searched the forums and found posts that said in future versions of gridview this should be possible, is it possible now?
  2. Svett
    Svett avatar
    728 posts

    Posted 19 Dec 2009 Link to this post

    Hello Vahagn Hokhikyan,

    Regarding the input validation you should subscribe to ValueChanging event of RadGridView where you may handle the value entered in the filter cell editor.

    Yes, you can change the editor in the filter row. You should use the following code in your case:

    public GridForm()
        this.radGridView1.MasterGridViewTemplate.EnableFiltering = true;
        this.radGridView1.EditorRequired += new EditorRequiredEventHandler(radGridView1_EditorRequired);
    private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
        if (this.radGridView1.CurrentRow is GridViewFilteringRowInfo)
            if (this.radGridView1.CurrentColumn.HeaderText == "ID")
                RadComboBoxEditor comboBox = new RadComboBoxEditor();
                RadComboBoxEditorElement editorElement = comboBox.EditorElement as RadComboBoxEditorElement;
                editorElement.DataSource = DataTableDumper.GenerateEmployees(20);
                editorElement.ValueMember = "ID";
                editorElement.DisplayMember = "Name";
                comboBox.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
                e.Editor = comboBox;

    If you have further questions, feel free to contact us.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top