W
Wysiwyg
I was hoping to get some opinions on the efficiency of various methods of
reusing the same dropdown list data.
Here is the situation:
Multiple panels on maintenance pages with TAB menus across the top showing
different panels. A DropDownList with a 50+ value/text entries exists on
more than one panel but only one will be displayed at a time. Examples might
be US states, countries, category codes, etc.
The query results the dropdownlists are bound to are stored in the
HttpContext.Current.Cache. The data isn't expected to change.
I can...
1. Create the dataset once during the initial page load and bind all
dropdown lists to the same dataset. EnableViewState = true for both
DropDownLists. Both DropDownLists will be in the viewstate sent to the
client and back to the server whether or not the panels are visible but I
won't have to rebind.
2. Turn viewstate off for and rebind the DropDownLists after each page load.
The query results are stored in the cache in an ArrayList of objects. I'd
have to rebind the controls after every load but the size of the viewstate
won't be increased by the data. The query won't be run every time as long as
the query's cache hasn't expired.
3. Put placeholders on the various panels of the web form, manually create a
complete, but non-displayed, DropDownList in code behind with the bound data
in it and store the entire control in the session state. During the
pre-render event of the appropriate panels I clear the placeholder and add
the saved DropDownList to it. I'll have to set the current selected value as
well. I'm not sure if the placeholder unique ID would have the selected
value in the Request.Form value though. I'd have to try it to see if I could
avoid manually placing a value in the viewstate when the selection is
changed. I'd want to clear the session state value when the page is
unloaded.
4. Same as #3 but use the HttpContext.Current.Cache instead of the session
state. The saved DropDownList would be shared with every session. This would
avoid even more querying when the data is fairly static.
I'd be interested in any other ways to efficiently handle DropDownList data.
Thanks for any replies,
Bill
reusing the same dropdown list data.
Here is the situation:
Multiple panels on maintenance pages with TAB menus across the top showing
different panels. A DropDownList with a 50+ value/text entries exists on
more than one panel but only one will be displayed at a time. Examples might
be US states, countries, category codes, etc.
The query results the dropdownlists are bound to are stored in the
HttpContext.Current.Cache. The data isn't expected to change.
I can...
1. Create the dataset once during the initial page load and bind all
dropdown lists to the same dataset. EnableViewState = true for both
DropDownLists. Both DropDownLists will be in the viewstate sent to the
client and back to the server whether or not the panels are visible but I
won't have to rebind.
2. Turn viewstate off for and rebind the DropDownLists after each page load.
The query results are stored in the cache in an ArrayList of objects. I'd
have to rebind the controls after every load but the size of the viewstate
won't be increased by the data. The query won't be run every time as long as
the query's cache hasn't expired.
3. Put placeholders on the various panels of the web form, manually create a
complete, but non-displayed, DropDownList in code behind with the bound data
in it and store the entire control in the session state. During the
pre-render event of the appropriate panels I clear the placeholder and add
the saved DropDownList to it. I'll have to set the current selected value as
well. I'm not sure if the placeholder unique ID would have the selected
value in the Request.Form value though. I'd have to try it to see if I could
avoid manually placing a value in the viewstate when the selection is
changed. I'd want to clear the session state value when the page is
unloaded.
4. Same as #3 but use the HttpContext.Current.Cache instead of the session
state. The saved DropDownList would be shared with every session. This would
avoid even more querying when the data is fairly static.
I'd be interested in any other ways to efficiently handle DropDownList data.
Thanks for any replies,
Bill