Can I pass a 2 dimensional array via Form?

Results 1 to 2 of 2

Thread: Can I pass a 2 dimensional array via Form?

  1. #1
    Join Date
    Dec 1969

    Default Can I pass a 2 dimensional array via Form?

    If so how? If not what are my options. Use the Session value? A little background to what I am trying to do. I have dumped a number of records into a 2 dimensional array. I want to display the result in Pages of 10 records. When I want to view the next 10 records, I want to avoid doing another DB call as I already have the data im my array. In order to view the next 10 records I need to change the values of 2 variables which I am currently doing through a recursive call and querystring. I hope I have made myself clear. Thanks in advance for any help.

  2. #2
    Join Date
    Dec 1969

    Default No but yes?

    You can&#039;t pass *ANYTHING* from ASP code to browser code *EXCEPT* as text. Meaning that you have to convert your array to a bunch of text to even *send* it out to the HTML to be stored in the form. <BR><BR>You can&#039;t pass *ANYTHING* from the browser back to ASP *EXCEPT* as text. Meaning that your ASP code will have to convert the textual form of the array (whatever you decide that is) into a VBScript array.<BR><BR>THIS IS THE NATURE OF HTTP and HTML and browsers and ...<BR><BR>Choices:<BR><BR>(1) Go ahead and write code to convert the 2D array to some textual form. Presumably, a very long string with one kind of delimiter between rows and a different kind between columns. Presumably you put this into some hidden form field so it can be posted back to the next page:<BR>&#060;%<BR>For row = 0 to numrows<BR>&nbsp; &nbsp; Response.Write "###" &#039; row mark?<BR>&nbsp; &nbsp; For col = 0 to numcols<BR>&nbsp; &nbsp; &nbsp; &nbsp; Response.Write "$$$" & yourArray(col,row)<BR>&nbsp; &nbsp; Next<BR>Next<BR>%&#062;<BR>Then, when you get that string back in the next ASP page, you convert the delimited string back into your array.<BR><BR>Can you say "UGH!" But it would work.<BR><BR>*********************<BR><BR>(2) Store the array as a Session value. See the ASPFAQs, category Arrays, for my discussion of how to do this. Easy, simple. Works great unless your site is very heavily loaded.<BR><BR>*********************<BR><BR>(3) Do the paging all in the client. Convert the VBS array into a client-side JS array.<BR><BR>To see a demo of the basic technique, look at my "Sorting in the client" demo at<BR><BR>That does sorting, instead of paging, in the client. But the principles would obviously be identical. Heck, why not do *both* sorting *and* paging in the client?<BR><BR>*************************<BR><BR>(4 ) Do *NONE* of the above if you have more than about 100 records to be paged through. Abandon it all and go to the conventional database paging techniques. Again, see the ASPFAQs, category Databases, General, and look for "paging".<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts