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

How to set FilterExpression manually using dates

10 Answers 763 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris Messineo
Top achievements
Rank 1
Chris Messineo asked on 04 Sep 2008, 11:44 PM
I want to do something like

RadGrid1.MasterTableView.FilterExpression = "SubmitDate >= '01/10/2008' and SubmitDate <= '02/01/2008'";
RadGrid1.Rebind();

But I get an error (something about a character literal can't be greater than 1 character).  SubmitDate is a DatTime field in the db.

Maybe this can't be done, not sure.

Any Ideas on how I can accomplish this?

Thanks

10 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Sep 2008, 07:32 AM
Hi Chris,

Try the following syntax for setting the date filter expression

protected void RadGrid1_PreRender(object sender, EventArgs e)   
    {   
        RadGrid1.MasterTableView.FilterExpression = "((["SubmitDate>= '1/10/2008') AND (["SubmitDate ] <= '02/11/2008')) ";   
        RadGrid1.MasterTableView.Rebind();   
    }  



Thanks,
Princy
0
Cheryl
Top achievements
Rank 1
answered on 05 Mar 2009, 09:53 PM
Hi,

This syntax didn't work for me and I'm also unable to get the filter expression to work for a datetime field.  Can you give me visual basic syntax that will work for a datetime filter expression for version : rad controls for asp.net ajax Q3 2008?

Thanks very much,
Cheryl Bearden
0
Yavor
Telerik team
answered on 06 Mar 2009, 06:51 AM
Hello Cheryl,

When applying the filter expression, can you please make sure that you have disabled the linq expressions (EnableLinqExpressions="false"). Let me know if this allows the filter expression to be properly applied.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Cheryl
Top achievements
Rank 1
answered on 06 Mar 2009, 12:50 PM
Hi Yavor,

Yes,  setting EnableLinqExpressions="false" did fix my problem.  Thank-you.

Cheryl
0
riccardo
Top achievements
Rank 1
answered on 20 Aug 2009, 07:00 AM
Hi,

I have the same problem (Character literal must contain exactly one character), setting EnableLinqExpressions = false didin't solve the problem

here my code:

 

filterExpression =

"Data_Acquisto >= '01/08/2009' and Data_Acquisto <= '02/11/2009'"

 


rgAssetHardware.MasterTableView.FilterExpression = filterExpression

rgAssetHardware.MasterTableView.Rebind()

0
Yavor
Telerik team
answered on 21 Aug 2009, 08:22 AM
Hi Riccardo,

If this did not help, there may be something particular to your case - for example, the way the control is created and bound to data. You can open a formal support ticket, and supply additional details, and a code snippet, or a small project, demonstrating the failing filter expression.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
riccardo
Top achievements
Rank 1
answered on 21 Aug 2009, 08:51 AM
Thank you!

For the moment I solved it using normal filtering without filtertemplate.
I will open the ticket later when I have more time to spend for this problem.
0
Yavor
Telerik team
answered on 21 Aug 2009, 12:26 PM
Hello Riccardo,

Okey, I will go ahead and close this thread. Whenever you have additional input on the case, you can open a formal support ticket, and let us know.
Good luck with your work!

Regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Harsh
Top achievements
Rank 1
answered on 02 Jun 2011, 10:49 AM
Hi the SortingDate given in the filter expression is the unique name of the GridBound column or is thiis the DataField of that column. As I am using columnModifiedOn as UniqueName and ModifiedOn as DataField but none seems to solve my issue.The grid doesn't get filtered at all.
0
Iana Tsolova
Telerik team
answered on 07 Jun 2011, 08:04 AM
Hello Harsh,

In the filter expression you should use the DataFIeld name.
Try setting the EnableLinqExpressions property of the grid to false if you are using SQL syntax to build the expression.

Regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Chris Messineo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Cheryl
Top achievements
Rank 1
Yavor
Telerik team
riccardo
Top achievements
Rank 1
Harsh
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or