Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:14:07+00:00 2026-05-29T05:14:07+00:00

So the past few weeks I’ve been working on a page that pulls from

  • 0

So the past few weeks I’ve been working on a page that pulls from a database and creates a gridview based off of drop down lists i had in place, so using ajax the gridview would change dependent on the ddls. The problem I was having was that while testing I’d change the ddl value, I’d follow a link in the given gridview and then i’d press back to check to see if the same gridview was displayed.
The gridview displayed however would be a different dataset than what i had just linked from, what would be displayed is a dataset that i had linked from earlier in my testing or none at all if it was my first attempt. I’d have to reload the page to view what i had cached programmatically.

So to fix this, i made an addendum to my ddl event- i tried to store the gridview and the ddl value in the cache and then on page load I checked to see if there existed a cache with those key values and databound those values: hoping that when the user pressed back the correct gridview would be displayed. It didn’t work; i had to force the cache to expire before my algorithm worked.

So were the two gridviews both being stored in the cache then and the browser was merely using it’s own key/value mapping initially? If so, how come even though i’m forcing the cache to expire, my programmatic caching works? Any clarifications?
as requested, here’s the code involved,

 //here's where i forced the cache to expire
    protected override void OnInit(EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
        Response.Cache.SetExpires(DateTime.MinValue);

        base.OnInit(e);
    }

And here’s another relevant snippet

   //Here's the code i used to check the value's i put in the cache
   if (Cache.Get("gvClassSchedule") != null)
            {
                IQueryable CachedgvClassSchedule = (IQueryable)Cache.Get("gvClassSchedule");
                CachedClassScheduleGv(CachedgvClassSchedule);
            }



   private void CachedClassScheduleGv(IQueryable CachedgvClassSchedule)
    {
        gvClassSchedule.DataSource = CachedgvClassSchedule;
        ddlClass.SelectedValue = Cache.Get("ddlClassValue").ToString();
        gvClassSchedule.DataBind();
        gvClassSchedule.Visible = true;
        divClassSchedule.Visible = true;

    }

where i’m storing my ddl value

      protected void OnChange_Class(object sender, EventArgs e)
    {
        if (ddlClass.SelectedValue != "-1")
        {
            classChanged();
            Cache.Insert("ddlClassValue", ddlClass.SelectedValue);
        }
        else
        {
            divClassSchedule.Visible = false;
            divExperiment.Visible = false;
        }
     }

where i’m storing my dataset

 private void classChanged()
    {
        if (ddlClass.SelectedValue != "-1")
        {
            Class course = dc.Classes.Single(p => p.ID == Convert.ToInt32(ddlClass.SelectedValue));
            ProfHasClassInSemester phcs = dc.ProfHasClassInSemesters.Single(p => p.ClassID.ToString() == ddlClass.SelectedValue && p.SemesterID.ToString() == ddlSemester.SelectedValue);

            lblClassAndProfessor.Text = ddlSemester.SelectedItem.Text + ": " + course.ClassName + " - " + phcs.Professor.ProfessorName;


            divClassSchedule.Visible = true;
            divExperiment.Visible = true;
            divAssign.Visible = false;
            addMode();
           IQueryable queryClassSchedule = fillClassScheduleGv(course);
            fillExperimentsddl();
            Session["ddlClass"] = ddlClass.SelectedValue;
            Cache.Remove("gvClassSchedule");

            Cache.Insert("gvClassSchedule", queryClassSchedule);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:14:08+00:00Added an answer on May 29, 2026 at 5:14 am

    You are using different caches in the different code examples.

    The Response.Cache is a HttpCachePolicy class – it sets HTTP headers that govern caching – this controls proxies and the browser cache.

    The second code snippet in the in memory cache – the Cache class from the System.Web.Caching namespace. This lives in the IIS memory space.

    In regards to the first – if you didn’t originally set the cache headers, you were probably loading the page from proxy/browser caches all this time. The server would not have been queries at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the past few weeks I have been working on an app that uses
I have been working on a scheduling website for the past few weeks. I
Off and on for the past few weeks I've been trying to find my
I've been working on a Django project for the past few weeks now, and
I've been working on a tabbed navigation idea for the past few weeks. I'm
In the past few weeks I've been developing a custom PHP login class that
For the past few weeks, I've been trying to learn about just how email
Over the past few weeks it seems like I've been interrupted by maintenance tasks
I have been learning Hibernate for the past few weeks, I have gotten most
I've been trying to learn Action Script 3 the past few weeks, making tiny

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.