If your "state" example is specifically a state example, then I'd probably
put them into a strongly typed dataset, and have the .xml to populate the
dataset handy.
Thinking outside of the State example. where you have a look up table...
that ~maybe changes every blue moon (in the db), then I usually do this:
1. Check the Application (or Session) for an existing copy.
2. If it doesn't exist, then read a fresh set out of the db, and put them
into the Application or Session object.
3. Return the Appliacation (or Session) copy.
I usually throw a "bool forceRefresh" parameter on it also. For that seldom
case that I make a change.
(Like, lets say I add a new state to the database. I'd call the function
with a "true" to make sure I refreshed the Application (or Session) data.
public ICollection RetrieveGoodEnoughStates( bool forceRefresh )
{
string keyname = "STATES";
ArrayList states;
bool readValuesFresh = false;
if (forceRefresh)
{
readValuesFresh = true;
}
else
{
if (null!=Session[keyname])
states = Session[keyname] as ArrayList;
}
else
{
readValuesFresh = true;
}
if (readValueFresh || null==states)
{
states = GetTheStatesFromDatabaseSomehow();
Session[keyname] = states;
}
return states;
}
Soemthing like that. YOu can clean it up, but you get the idea.
Check my blog:
http://sholliday.spaces.msn.com/ 10/24/2005 entry
for a object wrapper. Using this, I never use Session["keyname"], I use the
somewhat nicer wrapped object.
You could easily convert this to an ApplicationDataStore
"Ethan V" <aa*@aaa.aaa> wrote in message
news:OK**************@TK2MSFTNGP05.phx.gbl...
I have a few options regarding populating the state combo box
1. On page load, get the 50 states from the database
2. On application start, get the 50 states from the database and cache
them in application cache. On page load, get the states from application cache
3. Create a class in App Code folder, declare a public string array
property, hard code the 50 states. On page load, call this property to get
the 50 states
4. Create a states user control which contain a combo box, with 50 states
hard coded in design time
Please share with me how you usually bind your states combo box. Your
thoughts and recommendations are greatly appreciated.