Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Global : System.Web.HttpApplication
- {
- // The key to use in the rest of the web site to retrieve the list
- public const string ListItemKey = "MyListItemKey";
- // a class to hold your actual values. This can be use with databinding
- public class NameValuePair
- {
- public string Name{get;set;}
- public string Value{get;set;}
- public NameValuePair(string Name, string Value)
- {
- this.Name = Name;
- this.Value = Value;
- }
- }
- protected void Application_Start(object sender, EventArgs e)
- {
- InitializeApplicationVariables();
- }
- protected void InitializeApplicationVariables()
- {
- List<NameValuePair> listItems = new List<NameValuePair>();
- // replace the following code with your data access code and fill in the collection
- listItems.Add( new NameValuePair("Item1", "1"));
- listItems.Add( new NameValuePair("Item2", "2"));
- listItems.Add( new NameValuePair("Item3", "3"));
- // load it in the application object
- Application[ListItemKey] = listItems;
- }
- }
- <asp:DropDownList runat="server" ID="ddList" DataTextField="Name" DataValueField="Value"></asp:DropDownList>
- protected override void OnPreInit(EventArgs e)
- {
- ddList.DataSource = Application[Global.ListItemKey];
- ddList.DataBind();
- base.OnPreInit(e);
- }
- // Create and load the profile object
- x_siteprofile thisprofile = new x_siteprofile(Server.MapPath(String.Concat(config.Path, "templates/")));
- Application.Add("SiteProfileX", thisprofile);
Add Comment
Please, Sign In to add comment