How to use Telerik RadGrid FilterExpression on DataTable programmatically
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
Comments
-
Aleks K almost 2 years
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?
-
Kevin Kalitowski over 12 yearsYou can download System.Linq.Dynamic (.NET 4.0) from NuGet by searching for 'System.Linq.Dynamic'