Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to get outputparameter from cached ObjectDataSource ???

How to get outputparameter from cached ObjectDataSource ???

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JimFeng
    wrote on last edited by
    #1

    I need to get an outputparameter from a cached ObjectDataSource. Initially, I get outputparameter from OnSelected event of the ObjectDataSource: Protected Sub ods_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs) Cnt = e.OutputParameters("TotalCount") End Sub However, when an ObjectDataSource is not cached OnSelected is not fired. Any help is appreciated.

    M 1 Reply Last reply
    0
    • J JimFeng

      I need to get an outputparameter from a cached ObjectDataSource. Initially, I get outputparameter from OnSelected event of the ObjectDataSource: Protected Sub ods_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs) Cnt = e.OutputParameters("TotalCount") End Sub However, when an ObjectDataSource is not cached OnSelected is not fired. Any help is appreciated.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, When the SqlDataSource control has the EnableCaching set to true, and in subsequest requests the control will get the datasource persisted in the Cached object instead of re-executing the Sql command, so the event does not get fired as you may probably know. So I think you might need to persist the output value somewhere else on your own for later use.

      J 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, When the SqlDataSource control has the EnableCaching set to true, and in subsequest requests the control will get the datasource persisted in the Cached object instead of re-executing the Sql command, so the event does not get fired as you may probably know. So I think you might need to persist the output value somewhere else on your own for later use.

        J Offline
        J Offline
        JimFeng
        wrote on last edited by
        #3

        Thanks for your response. basically, I have a search page with a gridview that show the searched results. I need to use an output parameter to get a total record count for a gridview. The ObjectDatasSource of the gridview is Cache Enabled. If I cache the output value, when the gridview show a cached result set the cached ouput value would match the result. Do you have any other way to solve the problem?

        M 1 Reply Last reply
        0
        • J JimFeng

          Thanks for your response. basically, I have a search page with a gridview that show the searched results. I need to use an output parameter to get a total record count for a gridview. The ObjectDatasSource of the gridview is Cache Enabled. If I cache the output value, when the gridview show a cached result set the cached ouput value would match the result. Do you have any other way to solve the problem?

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          You can simply save the total value in the Cache object with the similar cache policy which is used to cache the search result in the ObjectDatasSource control. You basically refresh this cache item (the total count) when the ObjectDatasSource control executes the Select command again, it means you do this in the Selected event handler.

          J 1 Reply Last reply
          0
          • M minhpc_bk

            You can simply save the total value in the Cache object with the similar cache policy which is used to cache the search result in the ObjectDatasSource control. You basically refresh this cache item (the total count) when the ObjectDatasSource control executes the Select command again, it means you do this in the Selected event handler.

            J Offline
            J Offline
            JimFeng
            wrote on last edited by
            #5

            I did exactly what you said, but it wouldn’t work right. For example, first I search A1 and total count is 5. Then I search A2 and total count is 8. following if I search A1 again the total count will still stay on 8, since the Selected event will not be fired and the total account is not refreshed. This what I was talking about at beginning.

            M 1 Reply Last reply
            0
            • J JimFeng

              I did exactly what you said, but it wouldn’t work right. For example, first I search A1 and total count is 5. Then I search A2 and total count is 8. following if I search A1 again the total count will still stay on 8, since the Selected event will not be fired and the total account is not refreshed. This what I was talking about at beginning.

              M Offline
              M Offline
              minhpc_bk
              wrote on last edited by
              #6

              In this case, you need to refresh the control to display the search result for example GridView control using the ObjectDataSource.CacheKeyDependency[^] when you do a new search:

                  Cache\[ObjectDataSource1.CacheKeyDependency\] = new object();
                  GridView1.DataBind();
              
              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups