How to handle the cache and datasets??
I have been given an asp.net app with about 20 webpages, all using datagrids and a method for binding a dataset to the grid. it also has a simple DAL. Now, one of my tasks is to improve performance. So I figured caching the datasets was a good way to start. But, for most of the pages, all postbacks are caused by the user changing the search parameters and a new dataset has to be fetched from the DAL. That means caching is relativly useless? What do you think? Should I pursue it?
Also... one of the requirements, lets call it "nr 2" was that they want some pages to maintain viewstate between response.redirects... The users are tired of having to reselect search parameters when they press the "back button" (causing a hard coded response direct)
ANy suggestions how to solve it? As far as I know, viewstate for server controls are not maintained when the context changes? Am I wrong?
/Henrik
Re: How to handle the cache and datasets??
In relation to postbacks, you can use a simple piece of code:
VB Code:
Sub Page_Load( ... )
If Not IsPostBack Then
End If
End Sub
So. Just do the SQL stuff once, store into the cache, and then that's that.
In relation to storing user preferences, there are lots of ways of doing it. How are users selecting parameters, by tickboxes on forms or textboxes or what?
Re: How to handle the cache and datasets??
Yeah I already knew about the postback, thanks :) I don't think its what I need to solve my performance problem.. I will dig further... Have just spent 2 hours reading through tons of msdn articles on the subject... sessionstate, viewstate, cache tips and tricks ;)
Anyway, second problem... About remembering viewstate between calls... the first solution that comes into mind is to store the control indexes in the cache along wiht control ID... but is it the best way?? So if it isn't a postback, check the cache for the selectedindexes and textbox texts...
Or perhaps there is a way to dump the entire viewstate of an object to cache?? not just the properties... Perhaps a performance hit, but the quickest way to do it ;)
cya
Henrik
Re: How to handle the cache and datasets??
Well, the search criteria could not be that big correct?
I mean - you have a few true/falses, number ranges perhaps, or a few strings?
You can save those parameters into viewstate - or if you're worried about context, have you looked into attaching that information in to a cookie?