Variable loading of checkboxes from Caches

Visual Studio 2017 C#   -    

I have numerous checkboxes that are filled from a database.  When default page loads (and is not a postback) the lists are read from the database and placed into Caches.  

 Cache ACachce =  new Cache();
  ACachce.Insert(cacheName, ds, null, DateTime.Now.AddMinutes(10), Cache.NoSlidingExpiration,  CacheItemPriority.High, null);
  return ds;    // a dataset

When I redirect to another page (not postback) the Caches are used to fill the checkboxes.   For example:  
if (chkChiefComplaint.DataSource == null)
               chkChiefComplaint.DataSource = Cache["ChiefComplaint"];

Three other forms used the same checklists and read the Caches.  

My problem is that often (but not always) when redirecting to another page, the checkboxes are not filled.  If I return to the Default and then redirect back, the boxes are eventually filled, but it may take 2 to 3 rotations.    Once the boxes fill upon a page load they always filll  for any of the pages.  Sometimes the boxes fill correctly the first time a redirect is made.   The problem occurs in Chrome, IE, and Edge.   I have used try/catches to check for any errors.  

I do not know if it makes a difference, but these are Devexpress controls that are part of a Devexpress ASPX.FormLayout control.

I realize that this is a rather ambiguous problem, but any ideas or suggestions are greatly appreciated.

Vaughn Whitehead
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technology NinjaCommented:
Hi Vaughn,

1. Have you validated that cache are having these values filled in?
2. How are you making sure that someone is not overwriting the cache values? are these values unique for all users? Or cachename controls each unique user/group's checkbox settings?
3. Why are you expiring the values after 10 minutes? do you need to invalidate that frequently?

vaughnwhiteheadAuthor Commented:
1. I check for errors while assigning the Cache values.  After each read from the database, I have set breakpoints and examined the datasets to make sure they contain the correct data.  

2. No one is overwriting as everything is still on local host.  I was under the impression that Cache values were accessed by all users, while Session values were per user.

3. The lists rarely change.  I chose 10 minute for no particular reason. First time I have used a Cache.  


vaughnwhiteheadAuthor Commented:
Problem was declaring the Cache as a local variable.  Moved the declaration into a Class and it works fine.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.