Programatically Clear Cached Data (ObjectDataSource)

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
I want to clear cache on an object datasource through code, through Google I figured out from asp.net that if I do the following (where the original DefaultValue for the SelectParameter = "ORIGINAL"), the cache will get cleared:

C#:
ObjectDataSource1.SelectParameters[0].DefaultValue = "Original";

ObjectDataSource1.SelectParameters[0].DefaultValue = "ORIGINAL";

This in essence marks the parameter dirty causing the ObjectDataSource control to internally call OnParameterChanged which clears the cache (thank you Reflector!). This is a hack at best to get around the problem that there is no way to directly (that I've found) to clear the cache on ObjectDataSource progamatically.

What's the right way to do this progamatically?
 
Yeah, that doesn't work. The way I came up with the hack I did was by trying to clear the Cache manually and ran into the same thing he did...there's nothing in the Cache object! Count == 0.

Have you gotton this to work using this method? Maybe I'm just an idiot.
 
Back
Top