pnl_header.Controls.Add(Page.LoadControl("control\\header.ascx"));
pnl_body.Controls.Add(Page.LoadControl("control\\list_topic.ascx"));
And I have some information which is the same for each control and I do not want to do a SQL call every time for each control so I was wondering what is the best way to call the info once and then share the information between all the controls.
TIA.
AlvinYou could call on the sql on the first application load event. Then you could add the object to cache.
Cache["myCache"] = myDataSet; // for instance
if(Cache["myCache"]==null){
// Call a method to create the cache
}
esle{
myNewDataSet = (DataSet) Cache["myCache"];
}
Then you can retrieve the info from cache instead of hitting the db everytime.
You could also look at CacheDependencies as you can have the cache automatically refresh based on a change event - although this may not be necessary since you connecting to a db.
Hope that helps
This is just what I needed. Thanks Keith
0 comments:
Post a Comment