C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




ASP.NET 2.0: XmlDataSource - Default Caching Feature


Posted Date: 12 Sep 2006    Resource Type: Articles    Category: Web Applications
Author: Harish RanganathanMember Level: Gold    
Rating: Points: 10



Introduction


ASP.NET 2.0 has many performance enhancement features and the DataSource model is one of the important changes in ASP.NET 2.0. This article deals with the ASP.NET 2.0 XmlDataSource's Default Caching model.

XML DataSource


XmlDataSource is a wonderful Data Source control used to bind hierarchial data. It can be combined with a TreeView to display a Tree structure of Data to the users.


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


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.

Resolution


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.

Summary


The default caching behaviour that is specific only to Xml DataSource can sometimes be confusing since the underlying data changes arent reflected immediately.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."
Previous Resource: ASP.NET 2.0 - Enter Key - Default Submit Button
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use