Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:51:05+00:00 2026-06-02T18:51:05+00:00

I am storing multiple items into one session variable: which is 4 different words.

  • 0

I am storing multiple items into one session variable: which is 4 different words.

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?

_application just holds text from a series of text from text boxes.

Here is my session class.

 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; }
    }

Job application: Job application holds information from a list of textboxes thats it.

JobApplication _application;
_application = new JobApplication(jobID);
if (i < _applicant.Fields.Count)
                _applicant.AddAnswer((_controlsList[i] as TextBox).Text);
            else
                _application.AddAnswer((_controlsList[i] as TextBox).Text);

add to the session:

_sessions.ApplicationSession = _application;

I can get the session:

JobApplication application;
var jas = new JobApplicantSession();
application = jas.ApplicationSession;

Job application:

public class JobApplication
{
    private int _jobID = -1;
    public JobApplication(int jobID)
    {
        _jobID = jobID;
    }
    List<String> _answers = new List<String>();
    List<JobApplicationField> _fields = new List<JobApplicationField>();
    public List<JobApplicationField> Fields
    {
        get { return _fields; }
    }
    public int JobID()
    {
        return _jobID;
    }
    public List<String> 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 < _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 < _fields.Count; i++)
        {
            if (_fields[i].HasCorrectAnswer == true && _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<JobApplicationField>();
        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;
        }
    }
}
}

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:51:07+00:00Added an answer on June 2, 2026 at 6:51 pm

    Hope it is what you are asking. If you want to store array of objects in session state you can either sotre array directly:

     HttpContext.Current.Session["data"] = new int[32]; 
    

    or dynamically create names based on element index (strange, but possible):

     var data = new int[3];
     HttpContext.Current.Session["data" + 0.ToString()] = data[0]; 
     HttpContext.Current.Session["data"  + 1.ToString()] = data[1]; 
     HttpContext.Current.Session["data"  + 2.ToString()] = data[2]; 
    

    Read in reverse order:

    var dataArray = (int[])(HttpContext.Current.Session["data"]);
    

    or

     var data = new int[3];
     data[0] = (int)HttpContext.Current.Session["data" + + 0.ToString()]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long string (multiple paragraphs) which I need to split into a
For a JUnit test I need a String which consists of multiple lines. But
I am aggregating multiple List's into one List and would like to make it
one question how to store or return multiple queries result values into multiple variables..
Is there a way to separate a string into multiple lines like so: <cfset
I have a long string of comments that I'd like to split into multiple
How to insert multiple data into mssql without using loop? i'm developing a clinic
I am doing a project in ftp,which will do multiple uploads,and the process i
I am trying to select multiple items in a date picker defined as table,
I was like to update (retrieve and possibly edit) multiple items in an SQLite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.