|
-
Mar 4th, 2003, 09:53 PM
#1
Thread Starter
New Member
Dataset in a Server Control
I have written a custom server control, in which I use a dataset.
The dataset is passed into the control as a property, which I need to maintain for the life of the control.
My problem is that the after a postback on the page containing my control, the copy I was holding of the dataset, is no longer (ie ds = nothing).
Is there a way for me to retain the dataset between reloads of the page?
The only options I can see are to use a session variable, or to use a hidden field on the page. Are there any better options?
-Drew
-
Mar 4th, 2003, 10:33 PM
#2
PowerPoster
Probably the session variable would be best (or if the dataset is used across the whole app, then the Application variable would be best). If you embed it in a hidden field or try to keep it with the page, then you are transmitting that data to and from the client....creating much bigger load times for your pages if the dataset is populated with more than a couple items.
-
Mar 4th, 2003, 11:15 PM
#3
Thread Starter
New Member
That's what I thought.
My next question, then, is where are the appropriate places to place data into the session variable and when should I destroy the session variable.
Both the OnUnload event and Destroy method for the control are called b4 the page is displayed to the client. Far too early for a postback to occur. Leaving the data in the session object beyond the life of the control is also dangerous.
-Drew
-
Mar 4th, 2003, 11:48 PM
#4
PowerPoster
The session will time out after being inactive for a certain amount of time. This will in turn destroy the variables without you having to do anything. But, as you are probably saying, it is a waste to have that info in a session variable 20-30 minutes when the user has already left.
Couple things you can do (from my limited perspective, there is probably more):
You can adjust the timeout of the session (can't remember exactly where that is, but I know you can do it).
You can use a 'complex' way of destroying the session variable when the user navigates to another page in your app. This is to much trouble to me, but if performance is absolute key to your web app, the extra coding may be worth it. You would have to write code in each forms' load method to do destroy the dataset that is linked from that single page.
Or, you can do what I would do, just create a stored proceedure that returns the dataset your needing, and suck up the extra hits on the db for the data. If the data is medium in size, it shouldn't be that much extra strain on the server. I would try to eliminate most of the post backs required by your page though.
If you don't mind, I would like to see what you are doing as far as the code goes. Maybe I could help you figure something out. I have found that most of my pages only require data once during form load, then I don't re-process that code again when there is a post back.
-
Mar 5th, 2003, 12:17 AM
#5
Thread Starter
New Member
Unfortunately, none of those options are particularlly viable.
Session times will possibly be measured in hours, as this is a web based business app, with user logins.
As this is code is actually a custom composite control, I have no knowledge of where my data is coming from or what it means.
Essentially the control is based on an Infragistics UltraWebGrid with some extra actions/features piled on top.
My particular problem occurs when a user selects a data row and clicks a button, I need to return the selected rows data in an event. But, when the button is clicked the data in the web grid disapears b4 I can look at it. I have some client-side code that catches and holds which row was selected, but without the data to look up, a row index is useless.
The page using my control will provide data only when the page is not a postback, or I request a filter be applied. The data will most likely be sourced from a web service, although a generic query class (in-house) is being used.
I am not the one actually using the control, I just make the controls and document them.
Life in the web gets complicated very quickly. Sorry cannot really provide much code, but I hope this explanation clarifies my intent, somewhat.
-Drew
P.S. Thanks for the assistance hellswraith.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|