custom paging in datagrid

  • Thread starter Thread starter Mong
  • Start date Start date
M

Mong

Hi,

Does anyone have a "real" example of using custom paging with a
datagrid that retrieves data from a db? The online example just
inserts sample data each time which doesn't really illustrate how you
go about it, not sure why they bothered!

It says that your query should only return enough data to fill one
page which is obvious, but how do you tell a query to do that without
first getting all the data then working out where to jump in?

Currently I have an sql stored procedure which returns all rows to an
SqlClient.SqlDataReader. Can you jump into this kind of dataset using
an index?

Thanks for any insight,

Mong
 
Hi Mong,

For a datagrid you use the dataadapter, which fills a dataset in one time.

It is probably the same to find a working sample for a datagrid with a
datareader as to find a sample for a car which has a horse behind it.

Just my thoughts.

Cor
 
Cor,

Bet you already feel like an idiot after posting that so I'll let you
off...

Not sure why you're talking about "dataadapters" and "datasets", I
believe I only mentioned a "datareader", whether it be an
SqlDataReader or an OleDbDataReader is irrelevant which is why I
wasn't specific. But yes there are many ways to fill a datagrid as you
will/may learn in time.

Anyway as per usual problem solved quite easily, just grabbing the
number of records as specified by the datagrid's pagesize prop using
my own next/prev buttons, and storing the id of the first record of
each page. Atleast they'll be no surprises trusting MS code!

But thanks for the laugh Cor, no better way to start the day!

Mong

ps what the hell does "which fills a dataset in one time" mean? I hope
you don't mean that you're grabbing the entire recordset and keeping
it stored in memory whilst the page is alive. Nah surely no one's that
stupid hehe...
 
Hi Mong,

The datagrids in dotNet are made to work the Datasets, this is as well for
the webform as for the windowform, it is a kind of one by one relation.

The recordset which you mentioned is not used anymore except for VB6
compatible situations.

And yes you grab that whole dataset in one time. That does not mean that you
has to do, like often peolple did with the recordset, almost a complete
database in one time, but only that what you need.

I hope this helps?

Cor
 
Back
Top