Solved

Cached dropdownlist not consistent

Posted on 2008-10-29
8
249 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

615 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