Creating session variables from dynamically created controls

Posted on 2005-04-26
Medium Priority
Last Modified: 2010-04-07
I'm a relative newbie to ASP.net and I'm beginning to move into areas that seem beyond my current ability. For example I have created a form that uses a Placeholder to dynamically create a bunch of text boxes and drop down lists depending on the number of users specified earlier in the form.

I need to create session variables for each control in the placeholder.

That means I need to dynamically create session variables somehow.

So logically it would look something like (but I need the correct syntax)

For i = 1 to session("totalpeople")
 create "session("person" & i & "")"

All help is much appreciated.
Question by:gilkesy
LVL 26

Accepted Solution

Rejojohny earned 375 total points
ID: 13865134
For i = 1 to session("totalpeople")
    session("person" & i) = "UrSessionValue"          '..... for i

Author Comment

ID: 13865636
How do I load the session variable with the contents (.Text) of the dynamically created text field. Something like this:

        For i = 1 To Session("totalpeople")
            Session("InsuredFirstName" & i) = txtFirstName & i & .Text

Expert Comment

ID: 13873986
This doesn't seem like the best approach for this issue.  Why are you storing "totalpeople" in a session variable?  I'm sure you can accomplish what you want doing it the way you're trying, but I just don't think it's the right design pattern.  Could you post a little more information about what exactly you're trying to accomplish?

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question