Last post Mar 19, 2012 10:47 PM by robwscott
Mar 19, 2012 06:43 PM|obb-taurus|LINK
On my web form I have a gridview that in a user control which I have bound to a session, whenever there is a change made to a record in the web form I need to reload the updated data into the gridview. I've just been calling my function that loads the data
into my grid view in the first place but when I do this I always get an error saying that I need to enable session state on my page even though that's already the case. I don't know why but I got to wondering if my session needs to be cleared before I can
reload my data and before creating my session I call Session.Abandon(), after that I was able to reload my data with no problems.
What I'm wondering is if this is really what I should be doing or should I be taking a different approach in populating my gridview since there is a need to reload data after it's been changed?
Mar 19, 2012 10:47 PM|robwscott|LINK
honestly, there are a couple of points of what to use w/ session
1) dont ever use database connection strings in session
2) try to use only small variables and such. i don't know if you're passing your gridview in session but that tends to be an issue b/c it's so big
3) when passing variable values b/w pages, it's a good idea to use session
4) keep in mind that session only lasts until either there is a timeout, you clear the session, or the user leaves the website.
a good idea would be to just have your database call in a class and have your user control call this method to load your data into your gridview.
if you gridview has changed, and you don't need to reload it, then don't. you the programmer decide when and where to call the databind to the gridview, and decide when to load it. i would be more worried on LOSING the data in your session gridview rather
than making an extra couple of calls to my DB.
perhaps, instead of binding the gridview, you bind the List instead (if it's not that big), and then wherever you need your gridview, you have your List at hand. once again i don't really recommend this.