Where should I store a data table [ViewState/ Session/ Cache]

一笑奈何 提交于 2020-01-17 06:56:11

问题


I have a DataTable with about 10,000 rows in it.

I would like to store this data once for aspx page. When the user selects different options in the page, data is further selected from the already stored DataTable.

I tried using the ViewState, but as soon as the data grows beyond 100 rows, performance degrades.

Where should I store this data?


回答1:


Is the data on a per-user basis or is it global for all users? If it's global, use Cache. If it's user-specific, the traditional answer is to use Session, but that's a potential memory usage problem waiting to happen. You might just have to requery the database as needed.

ViewState has a more specific use, and it not suitable for large amounts of data, since all of that data is sent between the client and server in the webpage.




回答2:


I bet you must not be displaying all data together.

Why don't you use paging and load only required set of data and then keep on adding to session object, fetch first say 50 records display it and then on next page click fetch next set of 50 records.

You can use SP for this purpose http://www.mssqltips.com/sqlservertip/1699/sql-server-stored-procedures-to-page-large-tables-or-queries/



来源:https://stackoverflow.com/questions/2681971/where-should-i-store-a-data-table-viewstate-session-cache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!