protected void Page_Load(object sender, EventArgs e) { if (Session["Accounts List"] == null) { GenerateSessionObjects sessionGen = new GenerateSessionObjects(); } List <Account> allAccounts = (List <Account>)Session["Accounts List"]; Customer cust = (Customer)Session["customer"]; welcomeLabel.Text = "Welcome " + cust.FullName; foreach (Account acct in allAccounts) { allAccountsListbox.Items.Add(acct.Nickname); } }
protected void Page_Load(object sender, EventArgs e) { GenerateSessionObjects accountList = new GenerateSessionObjects(); var customer = accountList.GenerateCustomer(); foreach (var acct in accountList.GenerateAccounts()) { AccountListBox.Items.Add(acct.Nickname); if (Session[$"{acct.Nickname}Nickname"] == null) //Make sure a list item is selectd { Session[$"{acct.Nickname}Nickname"] = acct.Nickname; Session[$"{acct.Nickname}Balance"] = acct.Balance; Session[$"{acct.Nickname}Type"] = acct.Type; // Find all objects associated with item Session[acct.Nickname] = acct; Session[$"{acct.Nickname}FullName"] = customer.FullName; Session[$"{acct.Nickname}FullAddress"] = customer.FullAddress; } } NameLabel.Text = "Welcome " + customer.FullName; //add Name to the label }
protected void Page_Load(object sender, EventArgs e) { if (PreviousPage == null) { GenerateSessionObjects sessionobj = new GenerateSessionObjects(); Customer cust = (Customer)Session["custObj"]; List <Account> listObj = (List <Account>)Session["listObj"]; HttpContext.Current.Session["lbObj"] = AccountListBox.SelectedIndex; WelcomeLabel.Text = "Welcome " + cust.FullName; foreach (Account a in listObj) { AccountListBox.Items.Add(a.Nickname + a.Balance.ToString()); } } else { Customer cust = (Customer)Session["custObj"]; List <Account> listObj = (List <Account>)Session["listObj"]; //HttpContext.Current.Session["lbObj"] = AccountListBox.SelectedIndex; Session.Remove("lbObj"); Session.Add("lbObj", listObj); WelcomeLabel.Text = "Welcome " + cust.FullName; foreach (Account a in listObj) { AccountListBox.Items.Add(a.Nickname + a.Balance.ToString()); } } // HttpContext.Current.Session["lbObj"] = AccountListBox.SelectedIndex; // HttpContext.Current.Session["list"] = listObj; }