Last post Apr 27, 2006 12:20 PM by ranganh
Apr 27, 2006 12:20 PM|ranganh|LINK
While implementing XmlDataSource, we may not get the Data updated even though we change the underlying data, due to the built-in caching feature of this control.
Let us examine the following scenario.
We have a XML Fragment retrieved from Database based on a user input and set as the Data for the XmlDatasource. Then, when the user input changes, we would be getting a different XML Fragment from the Database. However,
you will find that when you bind the XmlDataSoruce to a control, the data doesnt change.
This is because, by default, the EnableCaching propery is set to "true". You can also find that the CacheDuration is set to "Infinite". This forces the Data in the XmlDataSource to be cached and hence the change
in the underlying Data, wont get reflected.
The resolution is to set the EnableCaching property to false or specify a CacheKeyDependency, or set the CacheDuration to a lesser time.
Since it is by default set for caching and we dont explicitly set it, it may be a little surprising to see the stale data when dealing with XmlDataSources.
This is not the same with other DataSources like SqlDataSource, ObjectDataSource etc., which have the EnableCaching property set to false, by default.