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

[Solved] CompositeFilterDescriptor.CreateFilterExpression crashing on DateTimes

1 Answer 420 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 05 Jan 2011, 05:17 PM
I'm trying to use a CompositeFilterDescriptor to filter the rows in my GridView.  My rows consist of strings, a bool, and a DateTime.  It works great if I take the DateTime out, but if I leave it in, I get a "No coercion operator is defined between types 'System.DateTime' and 'System.String'." error. Is there any way to use both strings and DateTimes in my GridView and a filter?

Thanks,
Michael

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Jan 2011, 10:34 AM
Hi Michael,

This indicates that you are trying to assign a string as the Value of a FilterDescriptor, whose MemberType is DateTime. Use a DateTime object, not a string and it will work.

For example,

var cfd = new CompositeFilterDescriptor();
cfd.FilterDescriptors.Add(new FilterDescriptor("DateColumn", FilterOperator.IsGreaterThan, DateTime.Now));
cfd.FilterDescriptors.Add(new FilterDescriptor("DateColumn", FilterOperator.IsLessThan, DateTime.Now.AddHours(1)));

For more info on working with filters, please read my blog posts:

Custom Filtering with RadGridView
Pre-filtering RadGridView
Pure Server-side Filtering  with RadGridView and WCF RIA Services

I hope this helps.

Best wishes,
Ross
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or