473,418 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Caching DataGrid Page

Hi All,

I'm having a problem with Page Output caching on a page that contains a
DataGrid. Basically the page pulls up some data for sales information from
the DB. Some of this has to be calculated on the fly when the request is
made, and so I thought it would be ideal to cache the page for a set amount
of time. I've placed the following at the top of my page: <%@ OutputCache
Duration="160" VaryByParam="None" %>
Now the problem is that this works fine if I am just looking at the
DataGrid, however it also needs to be editable. Once I click on the edit
link on the relevant row the page goes into the EditItemTemplate view and
stay's cached like this for the set period of time! Nothing can be done on
the page until the cache expires.

Is there a way of setting the caching policy to cache only when the DataGrid
is not in edit mode?
Nov 18 '05 #1
3 1614
Unfortunately, the caching model does not support this. You can "cache" the
data yourself, using a static (Shared VB.NET) method, but you will likely
cache data only, and not the actual grid. If the data is the same across all
sessions, until edited, you can use the Singleton pattern to store the data
and set a cache release time on the Singleton object (hits after this time
force a requery). You can then allow the data to be edited and stored in the
Singleton, as well as updated in the database.

None of this is automagic. You will have to write it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Janaka" <ja****@magicalia.com> wrote in message
news:eJ**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I'm having a problem with Page Output caching on a page that contains a
DataGrid. Basically the page pulls up some data for sales information from the DB. Some of this has to be calculated on the fly when the request is
made, and so I thought it would be ideal to cache the page for a set amount of time. I've placed the following at the top of my page: <%@ OutputCache Duration="160" VaryByParam="None" %>
Now the problem is that this works fine if I am just looking at the
DataGrid, however it also needs to be editable. Once I click on the edit
link on the relevant row the page goes into the EditItemTemplate view and
stay's cached like this for the set period of time! Nothing can be done on the page until the cache expires.

Is there a way of setting the caching policy to cache only when the DataGrid is not in edit mode?

Nov 18 '05 #2
Yeah about the same as what I was thinking. Do you think it would be
possible though to use the VaryByParam setting to vary by what the datagrid
clicks send to the browser?

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:er**************@TK2MSFTNGP10.phx.gbl...
Unfortunately, the caching model does not support this. You can "cache" the data yourself, using a static (Shared VB.NET) method, but you will likely
cache data only, and not the actual grid. If the data is the same across all sessions, until edited, you can use the Singleton pattern to store the data and set a cache release time on the Singleton object (hits after this time
force a requery). You can then allow the data to be edited and stored in the Singleton, as well as updated in the database.

None of this is automagic. You will have to write it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Janaka" <ja****@magicalia.com> wrote in message
news:eJ**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I'm having a problem with Page Output caching on a page that contains a
DataGrid. Basically the page pulls up some data for sales information

from
the DB. Some of this has to be calculated on the fly when the request is made, and so I thought it would be ideal to cache the page for a set

amount
of time. I've placed the following at the top of my page: <%@

OutputCache
Duration="160" VaryByParam="None" %>
Now the problem is that this works fine if I am just looking at the
DataGrid, however it also needs to be editable. Once I click on the edit link on the relevant row the page goes into the EditItemTemplate view and stay's cached like this for the set period of time! Nothing can be done

on
the page until the cache expires.

Is there a way of setting the caching policy to cache only when the

DataGrid
is not in edit mode?


Nov 18 '05 #3
The following is copied from MSDN. It describe the different ways you
can control caching. It looks like the "VaryByCustom" option can do
what you need.

VaryByCustom
Any text that represents custom output caching requirements. If this
attribute is given a value of browser, the cache is varied by browser
name and major version information. If a custom string is entered, you
must override the HttpApplication.GetVaryByCustomString method in your
application's Global.asax file.
VaryByHeader
A semicolon-separated list of HTTP headers used to vary the output
cache. When this attribute is set to multiple headers, the output
cache contains a different version of the requested document for each
specified header.
Note Setting the VaryByHeader attribute enables caching items in all
HTTP 1.1 caches, not just the ASP.NET cache. This attribute is not
supported for @ OutputCache directives in user controls.
VaryByParam
A semicolon-separated list of strings used to vary the output cache.
By default, these strings correspond to a query string value sent with
GET method attributes, or a parameter sent using the POST method. When
this attribute is set to multiple parameters, the output cache
contains a different version of the requested document for each
specified parameter. Possible values include none, *, and any valid
query string or POST parameter name.
CAUTION This attribute is required when you output cache ASP.NET
pages. It is required for user controls as well unless you have
included a VaryByControl attribute in the control's @ OutputCache
directive. A parser error occurs if you fail to include it. If you do
not want to specify a parameter to vary cached content, set the value
to none. If you want to vary the output cache by all parameter values,
set the attribute to *.
VaryByControl
A semicolon-separated list of strings used to vary a user control's
output cache. These strings represent the ID property values of
ASP.NET server controls declared in the user control. For more
information, see Caching Portions of an ASP.NET Page.
Note This attribute is required in a user control @ OutputCache
directive unless you have included a VaryByParam attribute. This
attribute is not supported for @ OutputCache directives in ASP.NET
pages.

Tommy,

"Janaka" <ja****@magicalia.com> wrote in message news:<eJ**************@TK2MSFTNGP12.phx.gbl>...
Hi All,

I'm having a problem with Page Output caching on a page that contains a
DataGrid. Basically the page pulls up some data for sales information from
the DB. Some of this has to be calculated on the fly when the request is
made, and so I thought it would be ideal to cache the page for a set amount
of time. I've placed the following at the top of my page: <%@ OutputCache
Duration="160" VaryByParam="None" %>
Now the problem is that this works fine if I am just looking at the
DataGrid, however it also needs to be editable. Once I click on the edit
link on the relevant row the page goes into the EditItemTemplate view and
stay's cached like this for the set period of time! Nothing can be done on
the page until the cache expires.

Is there a way of setting the caching policy to cache only when the DataGrid
is not in edit mode?

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
2
by: moondaddy | last post by:
My default page stays constant in the site and all the content in the body of the page is produced with user controls in a table cell for the body section. The main function of this site is a...
1
by: Fernando Chilvarguer | last post by:
HI, I have a page that users use to search for other users on my web site. Very simple page: - 3 input Parameters (TextBoxes) - 1 DataGrid with the search results. All works fine.
2
by: Raghu Raman | last post by:
Hi, In my asp .net page am using many controls and a grid.i populate many html controls innside the grid dynamically .if i click the grid ,it wll go to other page using onclick client side...
0
by: Simon Prince | last post by:
Hi I have created a .NET "Windows Custom Control" which is used an ASPX Web Form. It is referenced with the code, from a ASPX page. **************************************************...
0
by: syedsheeraz | last post by:
Hi all. Does anyone know if there is a way to gain programmatic access to the user control inside of a page after it has been cached? Let me elaborate more by telling you what I am doing. I am...
3
by: DC | last post by:
Hi, (ASP.Net 1.1) is it possible to (programmatically and globally) deactivate page fragment caching? We have only two scenarios, development stage where we want caching off and testing where we...
0
by: Not Me | last post by:
Hi, I've just been reading about paging a datagrid, and caching the data to avoid querying a database on every page update. When using a paged gridview in asp.net 2.0 is this caching taken...
3
by: jlotmar | last post by:
I am currently experiencing a problem whereby browser caching seems to be causing my page to be invalid. I am using a standard DataGrid WebControl which is bound to a DataView object. I use a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.