Link to home
Start Free TrialLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

How to Save datasource to be accessed after PostBack

I have a datalist in which I may display upto 5000 or more records. Since the viewsource becomes huge I have disabled viewsource on this page. I need to page the datalist. So how can I store and retrieve the data after the user clicks on Next Page? Should I store the data in Session? If so can I store the datatable in session? Thanks
Avatar of Mahone7
Mahone7
Flag of Qatar image

Yes, you can save DataTable in Session Just Try

DataTable dt = new DataTable(); //Or What Ever Datatable you want

Session["tblData"] = dt;

// To retrieve it from session
DataTable dt = (DataTable)Session["tblData"];

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TrialUser

ASKER

I am storing session in database and not in memory. Having said that is storing in session ok?
Currently there may be 100 users in a day. But the plan is too increase and support. I want to write a website that will be scalable and not have to worry about this in the future. Please suggest. Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
IS there any disadvantage of caching? Like memory?
Of course, caching uses memory, so overusing it can affect memory. If you describe your scenario more, I can help you with the design better.
I am developing an eCommerce website. ASP.NET/VB.NET 2010/SQL Server 2008.

The users can search for products. The search in some cases may return about 5000 records or more. The viewstate increases > 4MB in that case. One option for me would be to limit the records resultset to <1000. If I dont want to do that then I want to know what would be the best way to handle the records that are returned from the db.

Currently I have disabled the Viewsource in the page so the page does not crash after >5000 records.
Then how do I do paging sorting etc. Should I save the results in Session/Cache or do SQL paging (return only records that are displyed) and fetch the records everytime from the db.

Please help. Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial