This documentation is archived and is not being maintained.

ObjectDataSource.CacheKeyDependency Property

Gets or sets a user-defined key dependency that is linked to all data cache objects that are created by the data source control.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public virtual string CacheKeyDependency { get; set; }
/** @property */
public String get_CacheKeyDependency ()

/** @property */
public void set_CacheKeyDependency (String value)

public function get CacheKeyDependency () : String

public function set CacheKeyDependency (value : String)

Not applicable.

Property Value

A key that identifies all cache objects created by the ObjectDataSource.

The CacheKeyDependency property can be set to any arbitrary string value.

All cache objects are explicitly expired when the key is expired. This allows you to invalidate cache entries that are created by the ObjectDataSource from your own page code programmatically.

The ObjectDataSource control supports data caching. While data is cached, calls to the Select method retrieve data from the cache rather than from the business object that the ObjectDataSource works with. When the cache expires, the Select method retrieves data from the business object, and then caches the data again.


If you are not familiar with the Data Access features in ASP.NET 2.0, you should read some of these topics before continuing:

The ObjectDataSource control automatically caches data when the EnableCaching property is set to true and the CacheDuration property is set to a value greater than 0, which indicates the number of seconds that the cache stores data before the cache entry is discarded. A value of 0 indicates an infinitely long cache.

You can set the CacheKeyDependency property to create a dependency between all cache entries that are created by the ObjectDataSource control and the key. You can expire all the cache entries programmatically at any time by expiring the key. Expire the key by using the System.Web.Caching.Cache.Remove(System.String) method with the current CacheKeyDependency value as the parameter.

A unique cache entry is created for every combination of the CacheDuration, CacheExpirationPolicy, TypeName, SelectMethod, and SelectParameters properties. Multiple ObjectDataSource controls can use the same cache entries in scenarios where they load data using the same type, method, and parameters.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0