Creating session variables from dynamically created controls

Posted on 2005-04-26
Last Modified: 2010-04-07
I'm a relative newbie to 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

    For i = 1 to session("totalpeople")
        session("person" & i) = "UrSessionValue"          '..... for i

    Author Comment

    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
    LVL 9

    Expert Comment

    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

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now