Reputation: 7299
I am using devexpress GridView
in my c# application. So I initialize my GridView
like this:
gridControl.DataSource = new BindingList<ViewDomainClass.MaterialOffice.DAViewMTO>(_materialRepository.ViewMTOByDetail())
The output value of that is a List<DAViewMTO>
. So my user is able to filter the data in GridView
and I need just the data that my users filtered.
So I need to move these data (Filtered) to another list of type List<DAViewMTO>
How can I do that?
Upvotes: 1
Views: 11192
Reputation: 7299
Use this :
public static List<T> GetFilteredData<T>(ColumnView view)
{
List<T> resp = new List<T>();
for (int i = 0; i < view.DataRowCount; i++)
resp.Add((T)view.GetRow(i));
return resp;
}
And call like this :
ColumnView View = gridControl.MainView as ColumnView;
List<DAViewMTO> mydata= GetFilteredData<DAViewMTO>(View).ToList();
Upvotes: 1
Reputation: 18270
You can use two approaches to get filtered rows from GridView.
References:
Getting Filtered Rows
How to get filtered rows
XtraGrid GridView : How to get the filtered rows - If datasource is datatable
how to get the xtragrid filtered and sorted datasource?
If you didn't find the way to implement this then go through documentation to get correct methods to fetch the data.
Hope this help..
Upvotes: 3