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

  • SEARCH
  • Home
  • 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 7814601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:14:45+00:00 2026-06-02T05:14:45+00:00

I am creating text boxes dynamically. I want to take those text box values

  • 0

I am creating text boxes dynamically. I want to take those text box values and store them in a session so i can then store them in a database. How can i do this?

So, the way i am storing the DYNAMICALLY created textbox values is this way.

List<Control> _controlsList;
controlsList = new List<Control>();     // object holds the controls

Now, in my function i am adding them this way. Keep in mind i have 3+ textboxes

if (i < _applicant.Fields.Count)
                _applicant.AddAnswer((_controlsList[i] as TextBox).Text);
            else
                _application.AddAnswer((_controlsList[i] as TextBox).Text);
            _sessions.ApplicationSession = ((_controlsList[i] as TextBox).Text);
           // Session["TextboxValue"] = ((_controlsList[i] as TextBox).Text);

I have a session class

 public class JobApplicantSession
 {

   // public JobApplication ApplicationSession
    public string ApplicationSession
    {

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

      set{ HttpContext.Current.Session["Application"] = value; }
    }


}

I can add then but when i retrieve them from another class i only get the last added textbox. I need to be able to loop through so i can add those textbox values to a database but i cant loop through an object

var value = HttpContext.Current.Session["Application"]; //will get last textbox value
  • 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-02T05:14:48+00:00Added an answer on June 2, 2026 at 5:14 am

    Change your session class like

    public class JobApplicantSession
     {
    
       // public JobApplication ApplicationSession
        public string ApplicationSession
        {
    
          get {   if (HttpContext.Current.Session["Application"] == null)
                  HttpContext.Current.Session["Application"] = new List<string>();
               return (List<string>)HttpContext.Current.Session["Application"];
          }
    
        }
    
    
    }
    

    and add answer to list

     _sessions.ApplicationSession.Add((_controlsList[i] as TextBox).Text);
    

    you can loop now..

    foreach(string answer in _sessions.ApplicationSession )
    {
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating dynamic text boxes on button click and then showing values on
I am creating several text boxes depending on user choice (1-5).How can I access
im creating a list to update a MySql db with values form text boxes,
I'm creating some text boxes on my form programmatically which I need to reference
Hi I am creating a listbox containing 2 text boxes each time a user
I am creating a user control where in i have different HTML text boxes
I am creating a login register page which contains two edit text boxes(one for
I am trying something simple as creating a text file and then send it
I am creating a dynamic list of text boxes. when the user submits the
I am creating a site with lots of big scrollable text-boxes in it. Each

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.