There is a need to select 100 records by skipping 500. Can someone tell me if you can do offset and limit for a BindingSource?
1 answer
The solution depends on the data source.
If this is a DataTable, then you can use the View and filter by some criterion. It is possible and so dt.Rows.Cast<System.Data.DataRow>().Skip(n).Take(t).CopyToDataTable() It turns out that you skip n lines and take t. Moving to another page you increase n. It is necessary to keep remember the value of n.
Here is an example of how this can be implemented if there is no access to LINQ.
In a nutshell: you create a method that will explicitly iterate through cycles without LINQ to the original collection.
If this is a collection of objects, then you can create a new collection by calling Skip(n).Take(t) .
If you have access to LINQ, then the link above will also help you implement this logic.
- Source DataSet. Criterion, as I understand it, the sequence number can be? - Alexander Puzanov
- Well from the DataSet you choose the same specific table => in fact DataTable. - iluxa1810
- Yes, that is right. - Alexander Puzanov
- one@ Alexander Puzanov, I added the answer. - iluxa1810
- one@AlexanderPuzanov, I’m not sure, but it may be a matter of delayed execution. Did you check the returned collection in debugger? - iluxa1810