/// <summary> /// Retrieves valid users from database and binds form elements to users and characters available /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { InitUsers(); if (!IsPostBack) { DDDMUsers.DataSource = validUsers; DDDMUsers.DataBind(); DDCampaignUsers.DataSource = validUsers; DDCampaignUsers.DataBind(); UserDAO userDAO = new UserDAO(); DDCampaignCharacters.DataSource = userDAO.GetUserCharacters(validUsers[0].ID); DDCampaignCharacters.DataBind(); Session["userCharacters"] = userCharacters; Session["selectedUsers"] = selectedUsers; Session["selectedCharacters"] = selectedCharacters; } else { userCharacters = (List <Character>)Session["userCharacters"]; selectedUsers = (List <User>)Session["selectedUsers"]; selectedCharacters = (List <Character>)Session["selectedCharacters"]; } if (Session["generatedCampaign"] != null) { generatedCampaign = (Campaign)Session["generatedCampaign"]; } }
/// <summary> /// Populates the available characters with the selected user's characters /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DDCampaignUsers_SelectedIndexChanged(object sender, EventArgs e) { User selectedUser = validUsers[DDCampaignUsers.SelectedIndex]; UserDAO userDAO = new UserDAO(); userCharacters = userDAO.GetUserCharacters(selectedUser.ID); Session["userCharacters"] = userCharacters; DDCampaignCharacters.DataSource = userCharacters; DDCampaignCharacters.DataBind(); }