Friday, February 8, 2013

How to Get RadGrid Filtered DataSource

Below method will return the data source of the RadGrid after you have applied filters to the grid. We have assigned the current filter expression of the RadGrid to a string and then filter the DataTable by passing the filter expression.

First add the reference to the dynamic linq library. Download the dynamic linq library here. Add the following reference.

    using System.Linq.Dynamic;
    private DataTable GetFilteredDataSource()
        DataTable DT = new DataTable();
        DataTable FilteredDT = new DataTable();
        string filterexpression = string.Empty;
        filterexpression = RadGrid1.MasterTableView.FilterExpression;
        DT = (DataTable)RadGrid1.DataSource;
        FilteredDT = DT.AsEnumerable()
        return FilteredDT;

Write comments
Recommended Posts × +