Get multiple items in one session
<p>I am storing multiple items into one session variable: which is 4 different words.</p>

<p>I need to be able to take those 4 different wordsin the one session, and store them into separate variables so i can use them, is this possible? and if so how?</p>

<p>_application just holds text from a series of text from text boxes.</p>

<p>Here is my session class.</p>

<pre><code> public class JobApplicantSession
{

    public JobApplication ApplicationSession
    {

      get {if (HttpContext.Current.Session["Application"] != null)
               return (JobApplication)HttpContext.Current.Session["Application"];
           return null; }

      set{ HttpContext.Current.Session["Application"] = value; }
    }
</code></pre>

<p>Job application: Job application holds information from a list of textboxes thats it.</p>

<pre><code>JobApplication _application;
_application = new JobApplication(jobID);
if (i &lt; _applicant.Fields.Count)
                _applicant.AddAnswer((_controlsList[i] as TextBox).Text);
            else
                _application.AddAnswer((_controlsList[i] as TextBox).Text);
</code></pre>

<p>add to the session:</p>

<pre><code>_sessions.ApplicationSession = _application;
</code></pre>

<p>I can get the session:</p>

<pre><code>JobApplication application;
var jas = new JobApplicantSession();
application = jas.ApplicationSession;
</code></pre>

<p>Job application:</p>

<pre><code>public class JobApplication
{
    private int _jobID = -1;
    public JobApplication(int jobID)
    {
        _jobID = jobID;
    }
    List&lt;String&gt; _answers = new List&lt;String&gt;();
    List&lt;JobApplicationField&gt; _fields = new List&lt;JobApplicationField&gt;();
    public List&lt;JobApplicationField&gt; Fields
    {
        get { return _fields; }
    }
    public int JobID()
    {
        return _jobID;
    }
    public List&lt;String&gt; Answers
    {
        get { return _answers; }
        set { _answers = value; }
    }
    public void AddAnswer(String answer)
    {
        _answers.Add(answer);
    }
    public void AddField(JobApplicationField field)
    {
        if (field.HasFieldID)
        {
            for (int i = 0; i &lt; _fields.Count(); i++)
            {
                if (_fields[i].FieldID == field.FieldID)
                {
                    _fields[i] = field;
                    return;
                }
            }

        }

        _fields.Add(field);
    }
    public void PopulateFromDatabase()
    {
        JobPositionSystemDAL dal = new JobPositionSystemDAL();
        DataSet data = dal.OpenJobOpeningByID(_jobID);
        foreach (DataRow row in data.Tables[0].Rows)
        {
            JobApplicationField field = new JobApplicationField(Convert.ToInt32(row["QUESTIONID"]), row["QUESTIONTEXT"].ToString(), Convert.ToBoolean(row["HASCORRECTANSWER"]), row["CORRECTANSWER"].ToString(), Convert.ToBoolean(row["ISREQUIRED"]));
            AddField(field);
        }
    }
    public bool Verify()
    {
        if (_fields.Count != Answers.Count)
            throw new Exception("Number of answers != number of fields");
        for (int i = 0; i &lt; _fields.Count; i++)
        {
            if (_fields[i].HasCorrectAnswer == true &amp;&amp; _fields[i].CorrectAnswer != _answers[i])
                return false;
        }
        return true;
    }

    public void Save()
    {
        JobPositionSystemDAL database = new JobPositionSystemDAL();

        foreach(JobApplicationField field in _fields)
        {
            field.Save(_jobID, ref database);
        }

        //reload to get the Field/question ID for any new fields
        Reload();
    }

    public void Reload()
    {
        _fields = new List&lt;JobApplicationField&gt;();
        Load(_jobID);
    }

    public void Load(int jobID)
    {
        _jobID = jobID;
        DataSet ds = DB.OpenJobOpeningByID(jobID);
        DataTable table = ds.Tables[0];

        foreach (DataRow row in table.Rows)
        {
            int questionID = 0;
            object obj = row["QUESTIONID"];
            Int32.TryParse(obj.ToString(), out questionID);
            //int jobApplicationID = Int32.Parse(row["JOBAPPLICATIONID"] as String);
            string questionText = row["QUESTIONTEXT"] as String;
            int type = Int32.Parse(row["TYPEID"].ToString());
            bool hasCorrectAnswer = (row["HASCORRECTANSWER"] as String == "0") ? false : true;
            string correctAnswer = row["CORRECTANSWER"] as String;
            bool required = ((row["ISREQUIRED"] as String) == "0") ? false : true;

            JobApplicationField field = new JobApplicationField(questionID, questionText, hasCorrectAnswer, correctAnswer, required);
            AddField(field);
        }
    }
    private JobPositionSystemDAL _db;
    private JobPositionSystemDAL DB 
    {
        get
        {
            if (null == _db)
                _db = new JobPositionSystemDAL();
            return _db;
        }
    }
}
}
</code></pre>

<p>How can i loop through and store each item into its own variable?
i will need 4 variables.</p>
