Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatable select by row range c#

Tags:

c#-4.0

Does anyone know how to select datatable by row range? say if I need to pull out records in datatable from row #20 - #50.

like image 871
user384080 Avatar asked Oct 01 '10 03:10

user384080


People also ask

How can I get specific row from Datatable?

The DataTables rows() and row() (also optionally cells() and cell() ) methods provide the ability to select rows from the table. What rows are selected and how the selector actually operates is controlled by this row-selector data type.

What is DataRow C#?

A DataRow represent a row of data in data table. You add data to the data table using DataRow object. A DataRowCollection object represents a collection of data rows of a data table.

What is the row selector?

The row selector is a component that acts like a visual filter for datasets. It takes one dataset, chops it up into various ranges based on its configuration, and lets the user choose the splices. Then it creates a virtual dataset that only contains the rows that match the selected splices.


1 Answers

If you want to include rows 20 and 50, I think this will work:

var rows = (from r in table.AsEnumerable()
            select r).Skip(19).Take(31);

update:

or more succinctly:

var rows = table.AsEnumerable().Skip(19).Take(31);
like image 50
Jeff Ogata Avatar answered Nov 06 '22 11:11

Jeff Ogata