简体   繁体   中英

How to bind large amount of data into gridview?

Recently i went for an interview for c#.net programmer.The interviewer asked me a scenario which i could not answer,and couldnt find it by googling it

Scenario is like this..

Suppose we've about 100k customers in our database,I want to show them in a gridview,how will we do that ??

My answer was that we would fill customers in the datatable and bind it to the gridview.

He replied to me that there could be possible timeout scenario,when i bind it in the above mentioned way...

How could i solve this issue ???

Maybe with a paged Gridview. Don't you ask him for what answer he was waiting?

First thing is we have implement paging mechanism.

We can get certain number of records which can be shown in per page. On User click on second page, we will fetch next n number of records for display.

First thing is using pagination in the grid view.

If that isn't possible.. you can draw only one column (the IDs) and then draw all other fieds..

Yes. If you are simply using paging means, at each call it will have to fetch all records from database and display a small chunk of data as per the pagination applied.

What you can do is customize your pagination and call it in an eventhandler "OnPageIndexChanging", such a way that it will fetch only small chunk of data at each call and based on the next and prev selection it will re-query the database to get again a small amount of data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM