Cache.insert problem

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top