SetCacheControl

2 replies. Last post: May 27, 2010 2:56 AM by Glenn Layaar
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Brad LoveallMember

Hi,

I have a situation where I am trying to extend the cache from the default of five minutes to something more like 10 minutes and I'm not sure how to do this. The following code is taken from the InitializeDataSource event. This runs fine when I accept the normal WebGrid caching mechanism. It gets called after five minutes or so of inactivity and all is well. But when I try to extend it, by including the SetCacheControl() method, I get an error when this event is called during a FlyPostBack. The error is the familiar error where the grid just hangs and the circle in the lower left hand corner of the grid just goes round and round. I presume that it is related to the SetCacheControl call but am not certain. Is there a way to extend the cache timeout from five minutes to, say, ten minutes?

If Me.FieldsPopulated OrElse _
            WebGrid1.IsFlyPostBackRequest Then
            Try
                Dim dt As DataTable = Me.DoSearch()
                e.DataSource = dt

                If dt.Rows.Count = 0 Then
                    Me.DoSearch_NoResults()
                Else
                    Me.DoSearch_Results(dt.Rows.Count)
                End If

                Me.ApplyFilters()


                WebGrid1.SetCacheControl(New TimeSpan(0, 10, 0), CacheItemPriority.Normal)
                Me.DataSourceInitialized = True
            Catch ex As Exception
                Throw ex
            End Try
        End If

 

Thanks,

Brad

All times are GMT -5. The time now is 9:53 PM.
Previous Next