This is a migrated thread and some comments may be shown as answers.

Handling Input Errors in Gridview Filter Row

1 Answer 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vahagn Hokhikyan
Top achievements
Rank 1
Vahagn Hokhikyan asked on 18 Dec 2009, 03:14 AM
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?

1 Answer, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 19 Dec 2009, 08:47 AM
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()
{
    InitializeComponent();
 
    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,
Svett
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.
Tags
GridView
Asked by
Vahagn Hokhikyan
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or