views:

96

answers:

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:

http://stackoverflow.com/questions/2255269/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!