DataGrid Custom Paging using SQLDataReader

  • Thread starter Thread starter Paul Hobbs
  • Start date Start date
P

Paul Hobbs

Hi Everyone,

I am trying to implement a DataGrid that uses Custom paging, but the DataSource is a SQLDataReader, not a DataSet. I have seen examples that use the Fill method of a DataAdapter to only retrieve a page of data, eg:

daCustomers.Fill(dsCustomers, (PageNum - 1) * intPageSize, intPageSize, "Customers")

But I am having difficulties achieving this using a DataReader. My goal is to have a datagrid that only displays 10 rows of data at a time and allows the user to move between pages as well as allowing the user to sort the data - all without using a DataSet (not for any particular reason - I just want to do it this way)!

Cheers,

Paul
 
You are attempting to use a DataReader in a way for which it is not intended. DataReaders are for one time forward only reading of data out of a database. You can't "page" a DataReader because you can't go backwards.

Stick to the DataSet or a DataView based on a DataTable.
Hi Everyone,

I am trying to implement a DataGrid that uses Custom paging, but the DataSource is a SQLDataReader, not a DataSet. I have seen examples that use the Fill method of a DataAdapter to only retrieve a page of data, eg:

daCustomers.Fill(dsCustomers, (PageNum - 1) * intPageSize, intPageSize, "Customers")

But I am having difficulties achieving this using a DataReader. My goal is to have a datagrid that only displays 10 rows of data at a time and allows the user to move between pages as well as allowing the user to sort the data - all without using a DataSet (not for any particular reason - I just want to do it this way)!

Cheers,

Paul
 
Back
Top