开发者

How to mimic datagridview loading in SQL Server 2005

If you load a ton of records the DataGridView stays responsive as it loads records to the DataGridView bit by bit. How can this be done with a regular DataGridView and set of data coming from a database (I can't use straight data binding due to our data acc开发者_JAVA技巧ess layer).


As others have said, you will almost certainly want to implement paging at your data access layer to return small sets of data from the database.

Once you have that you can then consider either implementing user controlled paging (where they click a button to show the next or previous page - much like here on StackOverflow) or automatic paging.

For automatic paging (like you see in Excel) you need to implement Virtual mode in the DataGridView. There is quite a good example of this in this blog post.


Your data access layer needs to yield results before completing the query. It should implement IEnumerable or IDataReader. Then when you bind to it the first page of results should appear quickly.

Write a unit test that fetches only the first row, and a second unit test that fetches all rows. If both unit test take the same amount of time then you have problem in your DAL. Change your DAL so it yields rows early.


Can't you simply use paging and only query necessary number of rows per page from database? check this link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜