What am I missing here when I try to come back it resets the values to the old ones?
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.Xml;
using System.Threading;
using System.Data.SqlClient;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Configuration;
namespace CuprykWeb
{
// <summary>
/// Summary description for WebForm2.
/// </summary>
public class physicalcharacterics : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputImage InputImage7;
protected System.Web.UI.WebControls.ListBox lbPiercing;
protected System.Web.UI.WebControls.ListBox lbJewelry;
protected System.Web.UI.WebControls.ListBox lbTattoo;
protected System.Web.UI.WebControls.ListBox lbFashionSense;
protected System.Web.UI.WebControls.ListBox lbFacialHair;
protected System.Web.UI.WebControls.ListBox lbFacialShape;
protected System.Web.UI.WebControls.ListBox lbEyeColor;
protected System.Web.UI.WebControls.ListBox lbEyeWear;
protected System.Web.UI.WebControls.ListBox lbWeight;
protected System.Web.UI.WebControls.ListBox lbHeight;
protected System.Web.UI.WebControls.ListBox lbHairColor;
protected System.Web.UI.WebControls.ListBox lbHairStyle;
protected System.Web.UI.WebControls.ListBox lbComplexion;
protected System.Web.UI.WebControls.ListBox lbBodyType;
protected System.Web.UI.WebControls.ListBox lbAppearance;
protected System.Web.UI.WebControls.ListBox lbEthnicBackground;
protected System.Web.UI.WebControls.ListBox lbNationality;
protected MetaBuilders.WebControls.FirstFocus FirstFocus1;
protected System.Web.UI.HtmlControls.HtmlInputImage InputImage6;
static string m_strConnection = System.Configuration.ConfigurationSettings.AppSettings["sRegistration_FormDBConnectionString"]; // default connection string
static string batchSQL = "Select * FROM nationalities; Select * FROM ethnicbackgrounds; Select * FROM appearances; Select * FROM bodytypes; Select * FROM complexions; Select * FROM hairstyles; Select * FROM haircolors; Select * FROM heights; Select * FROM weights; Select * FROM eyewears; Select * FROM eyecolors; Select * FROM facialshapes; Select * FROM facialhairs; Select * FROM fashionsenses; Select * FROM tattoos; Select * FROM jewelrys; Select * FROM piercings";
static SqlDataAdapter title;
// create a SqlDataAdapter and use it to fill a DataSet SqlDataAdapter title;
//*********************************************************************************
public void lbAppearance_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbAppearance.SelectedItem != null)
{
Session["webform2_lbAppearance"] = lbAppearance.SelectedValue;
}
}
//*********************************************************************************
public void lbBodyType_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbBodyType.SelectedItem != null)
{
Session["webform2_lbBodyType"] = lbBodyType.SelectedValue;
}
}
//*********************************************************************************
public void lbNationality_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbNationality.SelectedItem != null)
{
Session["webform2_lbNationality"] = lbNationality.SelectedValue;
}
}
//*********************************************************************************
public void lbHeight_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbHeight.SelectedItem != null)
{
Session["webform2_lbHeight"] = lbHeight.SelectedValue;
}
}
//*********************************************************************************
public void lbWeight_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbWeight.SelectedItem != null)
{
Session["webform2_lbWeight"] = lbWeight.SelectedValue;
}
}
//*********************************************************************************
public void lbHairStyle_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbHairStyle.SelectedItem != null)
{
Session["webform2_lbHairStyle"] = lbHairStyle.SelectedValue;
}
}
//*********************************************************************************
public void lbHairColor_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbHairColor.SelectedItem != null)
{
Session["webform2_lbHairColor"] = lbHairColor.SelectedValue;
}
}
//*********************************************************************************
public void lbEyeWear_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbEyeWear.SelectedItem != null)
{
Session["webform2_lbEyeWear"] = lbEyeWear.SelectedValue;
}
}
//*********************************************************************************
public void lbEyeColor_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbEyeColor.SelectedItem != null)
{
Session["webform2_lbEyeColor"] = lbEyeColor.SelectedValue;
}
}
//*********************************************************************************
public void lbComplexion_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbComplexion.SelectedItem != null)
{
Session["webform2_lbComplexion"] = lbComplexion.SelectedValue;
}
}
//*********************************************************************************
public void lbFacialShape_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbFacialShape.SelectedItem != null)
{
Session["webform2_lbFacialShape"] = lbFacialShape.SelectedValue;
}
}
//*********************************************************************************
public void lbFacialHair_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbFacialHair.SelectedItem != null)
{
Session["webform2_lbFacialHair"] = lbFacialHair.SelectedValue;
}
}
//*********************************************************************************
public void lbEthnicBackground_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbEthnicBackground.SelectedItem != null)
{
Session["webform2_lbEthnicBackground"] = lbEthnicBackground.SelectedValue;
}
}
//*********************************************************************************
public void lbJewelry_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbJewelry.SelectedItem != null)
{
Session["webform2_lbJewelry"] = lbJewelry.SelectedValue;
}
}
//*********************************************************************************
public void lbFashionSense_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbFashionSense.SelectedItem != null)
{
Session["webform2_lbFashionSense"] = lbFashionSense.SelectedValue;
}
}
//*********************************************************************************
public void lbTattoo_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbTattoo.SelectedItem != null)
{
Session["webform2_lbTattoo"] = lbTattoo.SelectedValue;
}
}
//*********************************************************************************
public void lbPiercing_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbPiercing.SelectedItem != null)
{
Session["webform2_lbpiercing"] = lbPiercing.SelectedValue;
}
}
public void BindList(ref System.Web.UI.WebControls.ListBox MyList,
DataTable DataSource,
string ValueColumnName,
string TextColumnName
)
{
MyList.DataSource = DataSource;
MyList.DataTextField = TextColumnName;
MyList.DataValueField = ValueColumnName;
MyList.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
// Proccess values from Form2 and store them
if(!IsPostBack)
{
Thread.Sleep(5000);
// Evals true first time browser hits the page
if (Session["webform2_lbNationality"] != null)
for(int i=0;i<lbNationality.Items.Count;i++)
lbNationality.Items[i].Selected =true;
if (Session["webform2_lbEthnicBackground"] != null)
for(int i=0;i<lbEthnicBackground.Items.Count;i++)
lbEthnicBackground.Items[i].Selected =true;
if (Session["webform2_lbAppearance"] != null)
for(int i=0;i<lbAppearance.Items.Count;i++)
lbAppearance.Items[i].Selected =true;
if (Session["webform2_lbBodyType"] != null)
for(int i=0;i<lbBodyType.Items.Count;i++)
lbBodyType.Items[i].Selected =true;
if (Session["webform2_lbComplexion"] != null)
for(int i=0;i<lbComplexion.Items.Count;i++)
lbComplexion.Items[i].Selected =true;
if (Session["webform2_lbHairStyle"] != null)
for(int i=0;i<lbHairStyle.Items.Count;i++)
lbHairStyle.Items[i].Selected =true;
if (Session["webform2_lbHairColor"] != null)
for(int i=0;i<lbHairColor.Items.Count;i++)
lbHairColor.Items[i].Selected =true;
if (Session["webform2_lbHeight"] != null)
for(int i=0;i<lbHeight.Items.Count;i++)
lbHeight.Items[i].Selected =true;
if (Session["webform2_lbWeight"] != null)
for(int i=0;i<lbWeight.Items.Count;i++)
lbWeight.Items[i].Selected =true;
if (Session["webform2_lbEyeWear"] != null)
for(int i=0;i<lbEyeWear.Items.Count;i++)
lbEyeWear.Items[i].Selected =true;
if (Session["webform2_lbEyeColor"] != null)
for(int i=0;i<lbEyeColor.Items.Count;i++)
lbEyeColor.Items[i].Selected =true;
if (Session["webform2_lbFacialShape"] != null)
for(int i=0;i<lbFacialShape.Items.Count;i++)
lbFacialShape.Items[i].Selected =true;
if (Session["webform2_lbFacialHair"] != null)
for(int i=0;i<lbFacialHair.Items.Count;i++)
lbFacialHair.Items[i].Selected =true;
if (Session["webform2_lbFashionSense"] != null)
for(int i=0;i<lbFashionSense.Items.Count;i++)
lbFashionSense.Items[i].Selected =true;
if (Session["webform2_lbTattoo"] != null)
for(int i=0;i<lbTattoo.Items.Count;i++)
lbTattoo.Items[i].Selected =true;
if (Session["webform2_lbJewelry"] != null)
for(int i=0;i<lbJewelry.Items.Count;i++)
lbJewelry.Items[i].Selected =true;
if (Session["webform2_lbPiercing"] != null)
for(int i=0;i<lbPiercing.Items.Count;i++)
lbPiercing.Items[i].Selected =true;
DataSet ds = new DataSet();
title = new SqlDataAdapter (batchSQL, m_strConnection);
title.Fill (ds);
BindList(ref lbNationality, ds.Tables[0], "nationality_id", "nationality_name");
BindList(ref lbEthnicBackground, ds.Tables[1], "ethnicbackground_id", "ethnicbackground_name");
BindList(ref lbAppearance, ds.Tables[2], "appearance_id", "appearance_name");
BindList(ref lbBodyType, ds.Tables[3], "bodytype_id", "bodytype_name");
BindList(ref lbComplexion, ds.Tables[4], "complexion_id", "complexion_name");
BindList(ref lbHairStyle, ds.Tables[5], "hairstyle_id", "hairstyle_name");
BindList(ref lbHairColor, ds.Tables[6], "haircolor_id", "haircolor_name");
BindList(ref lbHeight, ds.Tables[7], "height_id", "height_name");
BindList(ref lbWeight, ds.Tables[8], "weight_id", "weight_name");
BindList(ref lbEyeWear, ds.Tables[9], "eyewear_id", "eyewear_name");
BindList(ref lbEyeColor, ds.Tables[10], "eyecolor_id", "eyecolor_name");
BindList(ref lbFacialShape, ds.Tables[11],"facialshape_id", "facialshape_name");
BindList(ref lbFacialHair, ds.Tables[12],"facialhair_id", "facialhair_name");
BindList(ref lbFashionSense,ds.Tables[13],"fashionsense_id", "fashionsense_name");
BindList(ref lbTattoo, ds.Tables[14], "tattoo_id", "tattoo_name");
BindList(ref lbJewelry, ds.Tables[15], "jewelry_id", "jewelry_name");
BindList(ref lbPiercing, ds.Tables[16], "piercing_id", "piercing_name");
}
} // PageLoad
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lbNationality.SelectedIndexChanged += new System.EventHandler(this.lbNationality_SelectedIndexChanged);
this.lbEthnicBackground.SelectedIndexChanged += new System.EventHandler(this.lbEthnicBackground_SelectedIndexChanged);
this.lbAppearance.SelectedIndexChanged += new System.EventHandler(this.lbAppearance_SelectedIndexChanged);
this.lbBodyType.SelectedIndexChanged += new System.EventHandler(this.lbBodyType_SelectedIndexChanged);
this.lbComplexion.SelectedIndexChanged += new System.EventHandler(this.lbComplexion_SelectedIndexChanged);
this.lbHairStyle.SelectedIndexChanged += new System.EventHandler(this.lbHairStyle_SelectedIndexChanged);
this.lbHairColor.SelectedIndexChanged += new System.EventHandler(this.lbHairColor_SelectedIndexChanged);
this.lbHeight.SelectedIndexChanged += new System.EventHandler(this.lbHeight_SelectedIndexChanged);
this.lbWeight.SelectedIndexChanged += new System.EventHandler(this.lbWeight_SelectedIndexChanged);
this.lbEyeWear.SelectedIndexChanged += new System.EventHandler(this.lbEyeWear_SelectedIndexChanged);
this.lbEyeColor.SelectedIndexChanged += new System.EventHandler(this.lbEyeColor_SelectedIndexChanged);
this.lbFacialShape.SelectedIndexChanged += new System.EventHandler(this.lbFacialShape_SelectedIndexChanged);
this.lbFacialHair.SelectedIndexChanged += new System.EventHandler(this.lbFacialHair_SelectedIndexChanged);
this.lbFashionSense.SelectedIndexChanged += new System.EventHandler(this.lbFashionSense_SelectedIndexChanged);
this.lbTattoo.SelectedIndexChanged += new System.EventHandler(this.lbTattoo_SelectedIndexChanged);
this.lbJewelry.SelectedIndexChanged += new System.EventHandler(this.lbJewelry_SelectedIndexChanged);
this.lbPiercing.SelectedIndexChanged += new System.EventHandler(this.lbPiercing_SelectedIndexChanged);
this.InputImage7.ServerClick += new System.Web.UI.ImageClickEventHandler(this.InputImage7_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void InputImage6_ServerClick(object sender, System.Web.UI.ImageClickEventArgs e)
{
Server.Transfer("signup.aspx", true);
}
public void InputImage7_ServerClick(object sender, System.Web.UI.ImageClickEventArgs e)
{
Server.Transfer("personalitytraits.aspx", true);
}
}
}