C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Cache


Posted Date: 05 Nov 2009    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: krishnavenikaladiMember Level: Gold    
Rating: 1 out of 5Points: 10



File based cache dependency:
The cache is expired when the data in the file changes

Step 1: Design an xml file with data
Step 2: Design webpage with grid view and button to submit

DataSet ds = null;
//defining cache variable
ds = (DataSet)Cache["ds1"];
if (ds == null)
{
ds = new DataSet();
//reading xml file
ds.ReadXml(Server.MapPath("product.xml"));
//defining cachedependency object based on filename
CacheDependency obj = new CacheDependency(Server.MapPath("product.xml"));
//populating cache with value ("key",value,cachedependency object)
Cache.Insert("ds1", ds, obj);
Response.Write("dataset from xml...");
}
else
{
Response.Write("from cache....");
}
//binding the data base schema & data
GridView1.DataSource = ds.Tables["product"];
GridView1.DataBind();




Explanation:
-->checks whether the dataset is empty or not
-->if it is empty it loads data from xml file else from cache
-->if modifications r done in file it expires the cache variable and data is loaded from xml file.



Responses

Author: ABitSmart    05 Nov 2009Member Level: Diamond   Points : 0
Please format your resource


Author: krishnavenikaladi    05 Nov 2009Member Level: Gold   Points : 0
hello abitsmart,
can u guide me how to format resource


Author: ABitSmart    05 Nov 2009Member Level: Diamond   Points : 1
Format your sentences for grammar. e.g., every sentence starts with a capital letter.

The best way to do is, copy your code into Word. It will automatically flag obvious spelling and grammar mistakes.


Author: krishnavenikaladi    05 Nov 2009Member Level: Gold   Points : 0
thank u.i have done the job!!


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Insert  .  Cachedependency  .  Cache  .  

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: Substitution control
Previous Resource: Get web page view source using C#
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use