MemoryLeak
MemoryLeak

Reputation: 7318

How to implement paging function in the datagrid when using data binding (winforms)?

I use data binding to control the datagrid, which connect to database table directly, what I want to do now is to implement the pager function on the datagrid, which I can only load 20 records from Database into memory, and display them. What do I know now is the the data binding will load all the records into database and then do some filtering and display in the control.. any suggestion ?

Upvotes: 0

Views: 896

Answers (2)

Stephan Keller
Stephan Keller

Reputation: 1633

Basicaly you have to run your datagrid in virtual mode, tell the grid how many rows there are in your recordset and then react to the CellValueNeeded-event. We implemented caching follwing this example on msdn .

Upvotes: 1

Timores
Timores

Reputation: 14589

You need to load 20 records at a time in your data source, i.e. you have to implement paging yourself. Each time the user requests a new page, you read the new set of records.

On the SQL side, 'sql paging' will get you lots of results from your favorite search engine and here is an example.

Upvotes: 1

Related Questions