problems with caching after the browser is shut

  • Thread starter Thread starter Neil Cooper
  • Start date Start date
N

Neil Cooper

Hi

Not sure if this the right group or not but here it goes.

Here is a part excerpt of my code in the Page_Load Event

'Create cache if the cache object doesn't exist yet
If IsNothing(Cache.Get("dsAllResults")) Then

' Use various SelectCommand to fill the 4 SqlAdapters

' Add all tables to a single data set
dsAllResults.Tables.Add(Client)
dsAllResults.Tables.Add(Calendar)
dsAllResults.Tables.Add(Result)
dsAllResults.Tables.Add(Remedy)

' Cache Data Set for 5 minutes
Cache.Add("dsAllResults", dsAllResults,
Nothing, DateTime.MaxValue, _
System.TimeSpan.FromMinutes(intCacheTimeout), _
Caching.CacheItemPriority.Default, Nothing)
Else
dsAllResults = Cache("dsAllResults")

End If
If Not (IsPostBack) Then
' Bind the client dropdown
drpClient.Items.Clear()

If Not (drpClient.SelectedItem Is Nothing)
Then
drpClient.SelectedItem.Text = ""
drpClient.SelectedItem.Value = ""
drpClient.SelectedItem.Selected = False

End If

drpClient.DataSource = dsAllResults.Tables
("Client")
drpClient.DataValueField = "ClientID"
drpClient.DataTextField = "Name"
drpClient.DataBind()
drpClient.Items.Insert(0, "")

End If
End Sub

This all works fine and has made the page run much
faster , the problem i have is if some one has shut the
browser down and they re-open it again.

The page loads again and opens from the cache fine but
when it gets to this point things go funny.

drpClient.DataSource = dsAllResults.Tables("Client")
drpClient.DataValueField = "ClientID"
drpClient.DataTextField = "Name"
drpClient.DataBind()
drpClient.Items.Insert(0, "")

Up until drpClient.DataBind() everything is fine, as soon
as stepped over drpClient.DataBind() the drpClient
already has the following properties already set.

drpClient.SelectedItem.Text = "Client Name"
drpClient.SelectedItem.Value = "156"
drpClient.SelectedItem.Selected = True

These are always the last selected client from the drop
down even after the browser is shut.

Has anybody had anything like this before , is the
autopostback on the dropdown updating the cache in
anyway , i'm at my wits end on this.

If anybody can help it would be most appreciated.


Thanks & Regards




Neil Cooper
 
I think you want to be putting those values into the session and not the
cache. I think the cache is for the whole application. I would check but my
msdn search feature keeps crashing (reboot time.)
 
Yes, I checked and cache is almost the same as the application cache. This
means that the data will shared for all users and expires only when the
application is recycled.
 
Back
Top