Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / February 2005

Tip: Looking for answers? Try searching our database.

Best practice approach for caching Dropdown list values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
oj - 24 Nov 2004 20:13 GMT
Could anyone provide some approaches that are used to cache dropdown
list control values to share globally beteween all users? Currently,
each time a page is loaded all the dropdown values for each dropdown
list control are retrieved from the database. I would like to go away
from this approach. Any info. is appreciated.
Scott M. - 24 Nov 2004 23:16 GMT
in the page_load event, populate your dropdown list when it isn't a postback
and don't when it's not.  ViewState will take care of persisting the list
values for you.  You don't need to do anything.

> Could anyone provide some approaches that are used to cache dropdown
> list control values to share globally beteween all users? Currently,
> each time a page is loaded all the dropdown values for each dropdown
> list control are retrieved from the database. I would like to go away
> from this approach. Any info. is appreciated.
oj - 25 Nov 2004 05:59 GMT
> in the page_load event, populate your dropdown list when it isn't a postback
> and don't when it's not.  ViewState will take care of persisting the list
> values for you.  You don't need to do anything.

I'm sorry if I wasn't clear. Currently, all dropdown controls for a
given page are loaded only once during the initial page load. What I
would like hear about are ways developers are sharing those dropdown
values globally between all users without having to run the query
against the db each time a page is accessed. Are there any approaches
being used that prevent having to access the database each time a page
is loaded to get the dropdown list values?
Scott M. - 25 Nov 2004 14:45 GMT
In the Global.asax file, you could go to your database in the
Application_Start event handler and fetch the values.  They could then be
stored in a Public Shared String array.  In the Page_Load event of the page
in question, you could load up the dropdown from the values in the array.

>> in the page_load event, populate your dropdown list when it isn't a
>> postback
[quoted text clipped - 8 lines]
> being used that prevent having to access the database each time a page
> is loaded to get the dropdown list values?
Ben Strackany - 29 Nov 2004 19:15 GMT
I'd suggest caching the dropdown. Two ways you could do it:

1. You could cache the database results. Use the Cache object to store the
DataSet/etc. that you load from the database. If the cache expires (for
whatever reason) you can re-populate the Cache by calling the database
again.

2. Or, you could cache the actual HTML of the dropdown. Create a user
control that contains the dropdown, and use partial-page output caching (or
fragment caching) to cache the HTML of that user control. That user control
will only call the database when it's created, & not while it's cached.

#1 might be a little easier to get started with, but #2 might give you
better performance in certain situations. Either approach is straightforward
enough. Check MSDN, GotDot net, ASP.NET QuickStart
(http://samples.gotdotnet.com/quickstart/aspplus/), or google for more
information on how to use caching. Good luck!

Signature

Ben Strackany
www.developmentnow.com

<a href="http://www.developmentnow.com">dn</a>

> > in the page_load event, populate your dropdown list when it isn't a postback
> > and don't when it's not.  ViewState will take care of persisting the list
[quoted text clipped - 7 lines]
> being used that prevent having to access the database each time a page
> is loaded to get the dropdown list values?
Mujahid.Net - 15 Feb 2005 10:43 GMT
You can use DataSet save methid to store db retrived data into an xml file
and populate the List from local XML dataset file! This can be used
irrespective of the session.

> > in the page_load event, populate your dropdown list when it isn't a postback
> > and don't when it's not.  ViewState will take care of persisting the list
[quoted text clipped - 7 lines]
> being used that prevent having to access the database each time a page
> is loaded to get the dropdown list values?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.