Solved

Cached dropdownlist not consistent

Posted on 2008-10-29
8
247 Views
Last Modified: 2013-12-17
Ive got a basic aspx page that loads a dropdown with employee names.  Since this data rarely changes, and since its around 6,000 names, I decided to cache the data using the code in the snippet.  My problem is that sometimes the dropdown has data..and sometimes it doesnt.  If I start a debug session and the dropdown is not filled, I can usually wait a minute or two then start the debugger back up and it will then be filled.  Why would it sometimes have data and other times be empty?  
if (Cache["employees"] == null)
            {
                DataTable dt = new DataTable();
                dt = employees.GetEmployees();
                Cache.Insert("employees", dt, null, DateTime.Now.AddMinutes(480), TimeSpan.Zero);
            }
 
            ddlEmployee.DataSource = (DataTable)Cache.Get("employees");
            ddlEmployee.DataTextField = "name";
            ddlEmployee.DataValueField = "emplid";
            ddlEmployee.DataBind();

Open in new window

0
Comment
Question by:clintfield
  • 3
  • 3
8 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 22906900
Hi clintfield,
May i know why you need to cache the data before output the resouces? It's not adviceable to use Cache in somehow. Please refer following articles for more details regarding Cache usage. Please check if you really need to use Cache in the existing code:
You may need to check why Cache object display inconsistenly for some reason:
Caching time and expiration:
http://ajdotnet.wordpress.com/2006/10/18/cache-as-cache-can/

0
 
LVL 1

Author Comment

by:clintfield
ID: 22906997
I could rewrite the code to supply the dropdown and then cache.  The real problem is that the dropdown sometimes doesnt have any data, even though it should have been cached.  I cached this particular dropdown because it contains a massive amount of names (I rechecked and there are actually 40,000+ names!) and it rarely changes.  It is also called regularly and sometimes more than once on the same page.
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 22907130
Hi clintfield,
That is too huge data for dropdownlist's resource. Perhaps you can try with other way instead of bind too large data in the dropdownlist. You can try use an AutoCompleteExtender instead.
http://forums.asp.net/t/1266932.aspx
 
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 1

Author Comment

by:clintfield
ID: 22907288
That looks sweet....but my company hasnt certified the toolkit yet so I cant use that.  ;-(
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 450 total points
ID: 22907456
Hi clintfield,
Then you can let them know how good it is compare with old solution. There are a lot of useful controls available for AJAX toolkit:
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx
Good luck to your project.

0
 
LVL 1

Author Comment

by:clintfield
ID: 22907468
Thanks for the ideas.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question