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

  • Home
  • SEARCH
  • 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 6073411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:16:05+00:00 2026-05-23T10:16:05+00:00

I’ve a Gridview control using an ODS(ObjectDataSource) to fetch data. For the best performance

  • 0

I’ve a Gridview control using an ODS(ObjectDataSource) to fetch data. For the best performance and efficiency, I’ve turned-off the view state of Gridview (i.e. EnableViewstate = “false”.

And I’ve also enabled caching in the associated Objectdatasource. This eliminates as much as 50-60% performance optimization because it eliminates the DB round-trip .. courtesy ODS Caching.

So, after this I got stuck into the famous “ODS sorting” issue but I managed to invent a tricky solution for it and its working fine:

Optimize Pagination & Sorting with ObjectDataSource having EnableCaching = true

Next pagination, it is also working fine. Now, I need to display “Total records: X” at the top of the Gridview. Well, I deployed the following method:

protected void ods_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if(e.ReturnValue != null && e.ReturnValue.GetType() == typeof(int))
                base.setTotalLabel(lblTotal, e.ReturnValue);
        }

Don’t confuse – base.setTotalLabel is my own method to set the label text with the count. This is also working fine but the issue is that –

Whenever, the ODS fetches data from
its Cache it won’t trigger the
ODS_Selecting or ODS_Select events.
They are simply “by-passed” because it
takes data from cache. This is when I
fail to refresh the Total records
count!

I hope I’ve explained my problem good, this is tricky. I’m ready to do any trick or dirty coding for this because I want to maintain the ODS-caching and I can’t rollback changes just because of a few incidental “mis-updates”.

Pls help!

  • 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-23T10:16:06+00:00Added an answer on May 23, 2026 at 10:16 am

    This worked for me I set the CacheKeyDependency and I explicitly set it to a new value whenever I want to refresh. I pass &refresh=1 in querystring if I want to explicitly refresh.

    In .aspx –

    <asp:ObjectDataSource ID="odsOrg" runat="server" SelectMethod="SearchOrg" ... EnableCaching="true" CacheDuration="60" CacheKeyDependency="key1">
    

    In code behind –

    public const string argRefresh = "refresh=1";
    public void CheckExpiredCacheKey(string ckey)
    {
     if (Cache[ckey] == null) 
      Cache[ckey] = new object(); //Set Cache key which will b used to manually expire ODS cache     
    
    if (!IsPostBack && Request.QueryString["refresh"] == "1")//check refresh flag
     {
        //Cache.Remove(ckey);//NOT NEEDED: use the following instead
        Cache[ckey] = new object();// Needed otherwise it'll call Grid-populate twice
     } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

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.