Reputation: 73
I have 2 pages 1 with Telerik RadGrid another with Telerik RadChart thay use the same DataTable. When I filtered RadGrid on the page I want to press the button and have the RadChart update to use the same filtered DataTable.
So first of all, here's what I've already tried.
With LINQ expressions turned off(EnableLinqExpressions="false"
), I can set the RadGrid filter expression (for example) as follows:
Grid.MasterTableView.FilterExpression = "([Date] LIKE '%21%')"
And now I can use:
private void SetFiltring(ref DataTable table)
{
table = table.Select("([Date] LIKE '%21%')", "").CopyToDataTable();
}
Its work great.
Now if I want to use LINQ expressions turned on(EnableLinqExpressions="true"
)
I can set the RadGrid filter expression (for example) as follows:
Grid.MasterTableView.FilterExpression = "it["Date"].ToString().ToUpper().Contains("21".ToUpper()))"
And now i dont know how to use this FilterExpression on DataTable . How can use this FilterExpression on DataTable.And Will Linq be faster than MSSQL Server syntax?
Upvotes: 2
Views: 11782
Reputation: 73
The problam was in .NET Framework 3.5 SP1 .for use Dynamic expressions i have to use
using System.Linq;
and using System.Linq.Dynamic;
and than i can use Linq:
private void SetFiltring(ref DataTable table)
{
table = table.AsEnumerable()
.AsQueryable()
.Where("it["Date"].ToString().ToUpper().Contains("21".ToUpper()))")
.CopyToDataTable();
}
and now it will work
Upvotes: 5
Reputation: 8598
If you'd like to do it the same way you are applying a filter above, check out this blog post:
http://blogs.msdn.com/b/aconrad/archive/2007/09/07/science-project.aspx
In it he gives a codebase to use a linq expression and then a method to turn it into a datatable.
Then it's a matter of assigning your grid's datasource to the datatable.
Upvotes: 0