This is a migrated thread and some comments may be shown as answers.
How to trap bad filter expression in RadGrid
2 Answers 40 Views
This is a migrated thread and some comments may be shown as answers.
Dexter McCloud
Top achievements
Rank 1
Dexter McCloud asked on 19 Feb 2010, 03:37 PM
I have a date field in a RadGrid called, "DueDate".  I would like to make sure the user does not enter invalid data into the filter.  To contemplate matters, this date field may not always be present.  I may set the DueDate to an empty string in the grid ItemDataBound event depending on business rules.  So, the Due Date in the grid may be a valid date or an empty string.

Does anyone know how I can check the filter after the user clicks a filterig menu option so I can throw an error before the grid tries to rebind the data?

2 Answers, 1 is accepted

Sort by
0
Accepted
Schlurk
Top achievements
Rank 2
answered on 19 Feb 2010, 05:57 PM
Using this you can capture the filtering event and then either cancel it if you have a bad filter, or let it continue to execute the filtering:

    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.FilterCommandName) 
        { 
            if (logic) 
            { 
                e.Canceled = true
            } 
        } 
    } 

0
Dexter McCloud
Top achievements
Rank 1
answered on 19 Feb 2010, 09:15 PM
This worked perfectly.  Thanks!
Tags
Grid
Asked by
Dexter McCloud
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Dexter McCloud
Top achievements
Rank 1
Share this question
or