473,426 Members | 1,613 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,426 software developers and data experts.

Cache.insert problem

Hi there

I am using the following to take an account number from a datagrid in to
another page and use it to load specific details according to the account
number:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1), TableCell)
Cache.Insert("SearchAccountNumber", Ownercell1.Text & "%")
Server.Transfer("/Application/CustomerBasicInfo.aspx")
End If
End sub
*****

This works fine when the user clicks the grid the first time - but if the
BACK button is used in the browser and another entry in the datagrid
selected, the first selection remains in the cache and the first record keeps
coming back. If you hit refresh in the browser it intermittently works
correctly - but obviously this is not acceptable.

It would seem to me that the cache is not refreshing itself - I have tried
using cache.remove infront of the above but it makes no difference.... I feel
I am missing something obvious here.

If anyone knows - I would appreciate your input.

Thanks

Stuart
Nov 19 '05 #1
2 1687
Stuart...the cache isn't the right object for the job. Cache is shared
amongst all users..so you'll run into all types of
race-conditions...Consider placing things in the HttpContext.Item
collection...you can read more on this at:
http://odetocode.com/Articles/111.aspx

and on storage objects in general at:
http://www.openmymind.net/DataStorage/index.html
I think this will be the irst step in solving your problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Stuart" <St****@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Hi there

I am using the following to take an account number from a datagrid in to
another page and use it to load specific details according to the account
number:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1), TableCell) Cache.Insert("SearchAccountNumber", Ownercell1.Text & "%")
Server.Transfer("/Application/CustomerBasicInfo.aspx")
End If
End sub
*****

This works fine when the user clicks the grid the first time - but if the
BACK button is used in the browser and another entry in the datagrid
selected, the first selection remains in the cache and the first record keeps coming back. If you hit refresh in the browser it intermittently works
correctly - but obviously this is not acceptable.

It would seem to me that the cache is not refreshing itself - I have tried
using cache.remove infront of the above but it makes no difference.... I feel I am missing something obvious here.

If anyone knows - I would appreciate your input.

Thanks

Stuart

Nov 19 '05 #2
Thanks Karl

I tried that, but I think I need to store the variable for more than one
hit...

Therefore I have tried using Session.Add to store the variable instead -
again this works fine for the first attempt, but I don't seem to be able to
overwrite the session variable in the same way.

If on the first click of the datagrid I use Session.Add("Name", value) the
Server.Transfer takes me to the correct page and retireves data correctly
according to the variable stored on the previous page - all good...

I then click BACK in the browser which displays my datagrid again - I choose
another record in the datagrid and use, obviously, the same Session.Add code
as the first time - Is something going wrong here ? Am I using Session.Add in
the correct way - is it supposed to overwrite the content of the session
variable when it is not null ? I have an inkling that this is something to do
with the fact that I click BACK ?

I Am Confused.... any more ideas would be great !

Thanks again

"Karl Seguin" wrote:
Stuart...the cache isn't the right object for the job. Cache is shared
amongst all users..so you'll run into all types of
race-conditions...Consider placing things in the HttpContext.Item
collection...you can read more on this at:
http://odetocode.com/Articles/111.aspx

and on storage objects in general at:
http://www.openmymind.net/DataStorage/index.html
I think this will be the irst step in solving your problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Stuart" <St****@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Hi there

I am using the following to take an account number from a datagrid in to
another page and use it to load specific details according to the account
number:

Public Sub CustomerSearchGrid_ItemCommand(ByVal source As Object, ByVal e

As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
CustomerSearchGrid.ItemCommand
If e.Item.ItemIndex >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Controls(1),

TableCell)
Cache.Insert("SearchAccountNumber", Ownercell1.Text & "%")
Server.Transfer("/Application/CustomerBasicInfo.aspx")
End If
End sub
*****

This works fine when the user clicks the grid the first time - but if the
BACK button is used in the browser and another entry in the datagrid
selected, the first selection remains in the cache and the first record

keeps
coming back. If you hit refresh in the browser it intermittently works
correctly - but obviously this is not acceptable.

It would seem to me that the cache is not refreshing itself - I have tried
using cache.remove infront of the above but it makes no difference.... I

feel
I am missing something obvious here.

If anyone knows - I would appreciate your input.

Thanks

Stuart


Nov 19 '05 #3

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

Similar topics

3
by: Dave | last post by:
I am currently having a problem with retaining the cache in my asp.net application. I am trying to insert a small DataView into cache, then recall it on various pages throughout the site. When on...
1
by: Glenn | last post by:
Hi, I have a config XML file that I am using from the application cache. I have configured the entry with a remove callback to re-populate cache automatically when the XML file changes. All is...
4
by: Mat | last post by:
Hi, I've stumbled onto a problem when using the caching object in ASP.Net. I'm placing a static dataset to the cache as the data only changes once a day. Whilst writing to the cache I'm using...
13
by: Fernando Chilvarguer | last post by:
Hi, I'm retriving data from a database and storing it on the Cache Object using the following code: HttpContext.Current.Cache.Insert( cacheItemKey, contentDS, //THE DATASET WITH MY DATA...
2
by: Andrew | last post by:
I hope this doesn't sound too silly. I am trying to cache a datatSet. I have written the code below. I insert into the cache: Eg. i = 1. if (Cache == null) { Cache.Insert("testQuestion"+ i,...
5
by: Stan SR | last post by:
Hi, Some newbie questions.. :-) First, what is the namespace to use for the Cache class ? When I use this bit of code I get an error if (Cache==null) Cache.Insert("myUserList",userlist);...
1
by: =?Utf-8?B?ZGF2ZQ==?= | last post by:
I have an asp.net project with a business layer (project) that has a class called references. It loads up a data set and stores in cache with the following code. _cached =...
0
by: shaiknayeemuddin | last post by:
Hi, I am facing one problem, We have data in Oracle Table and fetching that data from Cache Database using link server concept. I am able to fetch data through Cache query in Cache Studio...
0
by: pmouse | last post by:
Hi Guys, I've written a templated lru cache based on the SGI version of STL. To use the class, simply write: lru_cache<key_type, data_type, cache_length, custom_containercache; cache.insert( key,...
2
by: =?Utf-8?B?Y2F0?= | last post by:
We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server SP2. We started experiencing the following issue with the web cache (the code is straightforward...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.