Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cached dropdownlist not consistent

Posted on 2008-10-29
8
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

 
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 1800 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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