How do I store an array of data between pages?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin Steadman

    How do I store an array of data between pages?

    Hope this makes sense!

    I'm building an ASP page which allows uses to add items to an invoice
    via a form, ie:

    Item No Part No Order No Quanity Units Price VAT
    ------- ------- -------- ------- ----- ----- ---
    .... ... ... ... ... ... ...

    <Add item> <Submit>

    What I want to do is have the user add one item at a time (because we
    dont know how many items are going to be added), and slowly build up
    an array of records.

    To do this the user will be persented with a form (as above) which
    they use to add the first item. They then click the <Add item>
    button. This will submit the data to an ASP script to be validated.
    The data is then added to an array and the user is returned to the
    invoice page.

    I will then display the line they have already entered beneath the
    item entry (shown above). They then add another line and click <Add
    item> and the process is repeated until all items have been added.
    Finally the user clicks Submit and the data is stored in the database.

    To do this I obviously need to store each new line in an array. But
    I've just realised that I cant do this unless I store the array itself
    in a session variable. Is this acceptable, or is another method
    available that would support this?

    TIA,

    Colin
  • Aaron Bertrand - MVP

    #2
    Re: How do I store an array of data between pages?

    Have you considered using a database? Also, you can always store a local
    array in the session, using Session("array" ) = localArray... just remember
    to bring it back local before trying to iterate through it or manipulate it.

    --
    Aaron Bertrand
    SQL Server MVP





    "Colin Steadman" <google@colinst eadman.com> wrote in message
    news:4062dca4.0 405130801.c2c75 7b@posting.goog le.com...[color=blue]
    > Hope this makes sense!
    >
    > I'm building an ASP page which allows uses to add items to an invoice
    > via a form, ie:
    >
    > Item No Part No Order No Quanity Units Price VAT
    > ------- ------- -------- ------- ----- ----- ---
    > ... ... ... ... ... ... ...
    >
    > <Add item> <Submit>
    >
    > What I want to do is have the user add one item at a time (because we
    > dont know how many items are going to be added), and slowly build up
    > an array of records.
    >
    > To do this the user will be persented with a form (as above) which
    > they use to add the first item. They then click the <Add item>
    > button. This will submit the data to an ASP script to be validated.
    > The data is then added to an array and the user is returned to the
    > invoice page.
    >
    > I will then display the line they have already entered beneath the
    > item entry (shown above). They then add another line and click <Add
    > item> and the process is repeated until all items have been added.
    > Finally the user clicks Submit and the data is stored in the database.
    >
    > To do this I obviously need to store each new line in an array. But
    > I've just realised that I cant do this unless I store the array itself
    > in a session variable. Is this acceptable, or is another method
    > available that would support this?
    >
    > TIA,
    >
    > Colin[/color]


    Comment

    • Patrice

      #3
      Re: How do I store an array of data between pages?

      Also you could do this client side. Clicking the button would just add a new
      "blank" line to the table client side and the user will submit the whole
      form when ready ??

      Patrice


      "Colin Steadman" <google@colinst eadman.com> a écrit dans le message de
      news:4062dca4.0 405130801.c2c75 7b@posting.goog le.com...[color=blue]
      > Hope this makes sense!
      >
      > I'm building an ASP page which allows uses to add items to an invoice
      > via a form, ie:
      >
      > Item No Part No Order No Quanity Units Price VAT
      > ------- ------- -------- ------- ----- ----- ---
      > ... ... ... ... ... ... ...
      >
      > <Add item> <Submit>
      >
      > What I want to do is have the user add one item at a time (because we
      > dont know how many items are going to be added), and slowly build up
      > an array of records.
      >
      > To do this the user will be persented with a form (as above) which
      > they use to add the first item. They then click the <Add item>
      > button. This will submit the data to an ASP script to be validated.
      > The data is then added to an array and the user is returned to the
      > invoice page.
      >
      > I will then display the line they have already entered beneath the
      > item entry (shown above). They then add another line and click <Add
      > item> and the process is repeated until all items have been added.
      > Finally the user clicks Submit and the data is stored in the database.
      >
      > To do this I obviously need to store each new line in an array. But
      > I've just realised that I cant do this unless I store the array itself
      > in a session variable. Is this acceptable, or is another method
      > available that would support this?
      >
      > TIA,
      >
      > Colin[/color]


      Comment

      • dlbjr

        #4
        Re: How do I store an array of data between pages?

        Use xml Client or server side.

        You can add to an xml data island on client side then send xml to client when ready.

        'from dlbjr

        'Unambit from meager knowledge of inane others,engender uncharted sagacity.


        Comment

        • Colin Steadman

          #5
          Re: How do I store an array of data between pages?

          [color=blue]
          >-----Original Message-----
          >Also you could do this client side. Clicking the button[/color]
          would just add a new[color=blue]
          >"blank" line to the table client side and the user will[/color]
          submit the whole[color=blue]
          >form when ready ??
          >
          >Patrice[/color]


          I didn't know that was possible. Presumably this is a
          javascript function?

          Incase I cant find any examples of this, do you happen to
          have any code that does this that you dont mind sharing?

          TIA,

          Colin

          Comment

          • Guest's Avatar

            #6
            Re: How do I store an array of data between pages?

            [color=blue]
            >-----Original Message-----
            >Have you considered using a database?[/color]


            No I hadn't. How would you see this working? Is it
            possible to setup a Transaction in this senario and submit
            it at the end? I'm not sure how you'd keep track of the
            transaction while skirting between pages.

            [color=blue]
            >Also, you can always store a local
            >array in the session, using Session("array" ) =[/color]
            localArray... just remember[color=blue]
            >to bring it back local before trying to iterate through[/color]
            it or manipulate it.[color=blue]
            >[/color]

            This was my original intention, but I thought this was a
            big no no. Is it acceptable to do this? We wont have
            many users, at a guess I'd say 50 with no more then 15
            logged on at any one time. If I can do this, I'll do it!

            TIA,

            Colin

            Comment

            • Roland Hall

              #7
              Re: How do I store an array of data between pages?

              "Colin Steadman" wrote in message
              news:4062dca4.0 405130801.c2c75 7b@posting.goog le.com...
              : Hope this makes sense!
              :
              : I'm building an ASP page which allows uses to add items to an invoice
              : via a form, ie:
              :
              : Item No Part No Order No Quanity Units Price VAT
              : ------- ------- -------- ------- ----- ----- ---
              : ... ... ... ... ... ... ...
              :
              : <Add item> <Submit>
              :
              : What I want to do is have the user add one item at a time (because we
              : dont know how many items are going to be added), and slowly build up
              : an array of records.
              :
              : To do this the user will be persented with a form (as above) which
              : they use to add the first item. They then click the <Add item>
              : button. This will submit the data to an ASP script to be validated.
              : The data is then added to an array and the user is returned to the
              : invoice page.
              :
              : I will then display the line they have already entered beneath the
              : item entry (shown above). They then add another line and click <Add
              : item> and the process is repeated until all items have been added.
              : Finally the user clicks Submit and the data is stored in the database.
              :
              : To do this I obviously need to store each new line in an array. But
              : I've just realised that I cant do this unless I store the array itself
              : in a session variable. Is this acceptable, or is another method
              : available that would support this?

              Where does the user get the information to input from? Are these select
              lists or text boxes? And, how many items in each column? This sounds like
              a shopping cart.

              --
              Roland Hall
              /* This information is distributed in the hope that it will be useful, but
              without any warranty; without even the implied warranty of merchantability
              or fitness for a particular purpose. */
              Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
              WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
              MSDN Library - http://msdn.microsoft.com/library/default.asp



              Comment

              • Colin Steadman

                #8
                Re: How do I store an array of data between pages?

                [color=blue]
                >Where does the user get the information to input from?[/color]

                Its basically a page which will allow the user to add line
                items from an invoice onto the database. An invoice will
                always have a minimum of 1 item, but is more likely to
                have many. For this reason I want the user to add one
                item at a time. My idea is that the user will add the
                data for item 1 and click an ADD ITEM Button. This will
                add the item to an array back at the server. The invoice
                entry page will then regenerate and add the added item
                into a table. Above the table will be the form where they
                can continue to add new items. I hope thats clear enough,
                I dont think I'm describing this very well.


                [color=blue]
                > Are these select lists or text boxes? And, how many
                > items in each column?[/color]


                All are text boxes, and there are only a dozen of them.

                [color=blue]
                >This sounds like a shopping cart.
                >[/color]


                How do those work? I've not done any e-Commerce type apps!

                TIA,

                Colin

                Comment

                • Patrice

                  #9
                  Re: How do I store an array of data between pages?

                  See :


                  Also you could copy a whole row (instead of adding each element in script)
                  to have a general function.

                  The simplest way would be just to display let's say 10 rows. The user will
                  posbatck if he needs more row... Server side you'll just ignore unused
                  rows...

                  Patrice

                  "Colin Steadman" <msdn@N0Tpart0F emailADdRESSSco linsteadman.com > a écrit dans
                  le message de news:ceb701c439 83$d4a1a980$a10 1280a@phx.gbl.. .[color=blue]
                  >[color=green]
                  > >-----Original Message-----
                  > >Also you could do this client side. Clicking the button[/color]
                  > would just add a new[color=green]
                  > >"blank" line to the table client side and the user will[/color]
                  > submit the whole[color=green]
                  > >form when ready ??
                  > >
                  > >Patrice[/color]
                  >
                  >
                  > I didn't know that was possible. Presumably this is a
                  > javascript function?
                  >
                  > Incase I cant find any examples of this, do you happen to
                  > have any code that does this that you dont mind sharing?
                  >
                  > TIA,
                  >
                  > Colin[/color]


                  Comment

                  • Aaron Bertrand - MVP

                    #10
                    Re: How do I store an array of data between pages?

                    > No I hadn't. How would you see this working? Is it[color=blue]
                    > possible to setup a Transaction in this senario and submit
                    > it at the end? I'm not sure how you'd keep track of the
                    > transaction while skirting between pages.[/color]

                    I envision two tables, much like in an e-commerce app. Cart and
                    CartDetails. When the user first adds an item to the shopping cart, you
                    make an entry into the Cart table, then a child row in CartDetails. You
                    bring back the CartID (e.g. IDENTITY) to the ASP page, and use this in a
                    session variable. When the user adds another item to the cart, you just
                    associate the session("CartID ") and add another row to the cart details
                    table.

                    One of the advantages here is that this outlives session timeouts. You can
                    also go without cookies, by persisting the CartID in a querystring or form
                    variable throughout the site.
                    [color=blue]
                    > This was my original intention, but I thought this was a
                    > big no no. Is it acceptable to do this? We wont have
                    > many users, at a guess I'd say 50 with no more then 15
                    > logged on at any one time. If I can do this, I'll do it![/color]

                    Shouldn't be a problem. Objects and arrays are very different things.

                    --
                    Aaron Bertrand
                    SQL Server MVP



                    Comment

                    • Michael D. Kersey

                      #11
                      Re: How do I store an array of data between pages?

                      Colin Steadman wrote:[color=blue]
                      > Hope this makes sense!
                      >
                      > I'm building an ASP page which allows uses to add items to an invoice
                      > via a form, ie:
                      >
                      > Item No Part No Order No Quanity Units Price VAT
                      > ------- ------- -------- ------- ----- ----- ---
                      > ... ... ... ... ... ... ...
                      >
                      > <Add item> <Submit>
                      >
                      > What I want to do is have the user add one item at a time (because we
                      > dont know how many items are going to be added), and slowly build up
                      > an array of records.
                      >
                      > To do this the user will be persented with a form (as above) which
                      > they use to add the first item. They then click the <Add item>
                      > button. This will submit the data to an ASP script to be validated.
                      > The data is then added to an array and the user is returned to the
                      > invoice page.
                      >
                      > I will then display the line they have already entered beneath the
                      > item entry (shown above). They then add another line and click <Add
                      > item> and the process is repeated until all items have been added.
                      > Finally the user clicks Submit and the data is stored in the database.
                      >
                      > To do this I obviously need to store each new line in an array. But
                      > I've just realised that I cant do this unless I store the array itself
                      > in a session variable. Is this acceptable, or is another method
                      > available that would support this?
                      >
                      > TIA,
                      >
                      > Colin[/color]
                      There's nothing wrong with storing an array in a session variable. But
                      warn the users not to take coffee breaks between item entries: session
                      variables are deleted when the session times out, usually 20 minutes
                      (but you can change it). Also, the users' browsers must be set to accept
                      cookies for session variables to be accessible.

                      Other choices: store the data Application variables, in a database or to
                      a file on the server. All 3 methods will persist data beyond
                      end-of-session, although Application variables disappear if IIS is
                      restarted.

                      You can also store the data on the user's form as hidden or visible
                      fields, but in using this method remember that there is the possibility
                      that the user could change already-entered values (by modifying the
                      hidden fields with a program or manually).

                      Good Luck,
                      Michael D. Kersey

                      Comment

                      • Roland Hall

                        #12
                        Re: How do I store an array of data between pages?

                        "Colin Steadman" wrote in message
                        news:d10a01c439 a7$951b6a20$a50 1280a@phx.gbl.. .
                        :
                        : >Where does the user get the information to input from?
                        :
                        : Its basically a page which will allow the user to add line
                        : items from an invoice onto the database. An invoice will
                        : always have a minimum of 1 item, but is more likely to
                        : have many. For this reason I want the user to add one
                        : item at a time. My idea is that the user will add the
                        : data for item 1 and click an ADD ITEM Button. This will
                        : add the item to an array back at the server. The invoice
                        : entry page will then regenerate and add the added item
                        : into a table. Above the table will be the form where they
                        : can continue to add new items. I hope thats clear enough,
                        : I dont think I'm describing this very well.
                        :
                        : > Are these select lists or text boxes? And, how many
                        : > items in each column?
                        :
                        : All are text boxes, and there are only a dozen of them.
                        :
                        : >This sounds like a shopping cart.
                        :
                        : How do those work? I've not done any e-Commerce type apps!

                        Ok, a few of more questions...

                        Is the user entering data from a hard copy invoice?
                        What is the average number of items on a given invoice?
                        How many users will enter data simultaneously?
                        Will these items ever be duplicated? ...meaning will they enter widget #1
                        more than once, ever?
                        What will you do with the data once it is entered?

                        A shopping cart allows you to select products you would like to purchase, as
                        you would use a basket in a grocery store and then purchase them either CC
                        online, CC phone or mail-in check/money order.

                        --
                        Roland Hall
                        /* This information is distributed in the hope that it will be useful, but
                        without any warranty; without even the implied warranty of merchantability
                        or fitness for a particular purpose. */
                        Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
                        WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
                        MSDN Library - http://msdn.microsoft.com/library/default.asp


                        Comment

                        Working...