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";