How to get outputparameter from cached ObjectDataSource ???
-
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.
-
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.
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.
-
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.
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?
-
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?
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.
-
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.
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.
-
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.
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();