NameValueCollection, Request.QueryString, WebForm usage 
Author Message
 NameValueCollection, Request.QueryString, WebForm usage

In a WebForm I am trying to use the NameValueCollection and
to parse the QueryData from a URL. An example from MSDN shows the following:

 Dim loop1, loop2 As Integer
 Dim arr1(), arr2() As String
 Dim coll As NameValueCollection
 coll=Request.QueryString ' Load Form variables into NameValueCollection
 arr1 = coll.AllKeys ' Get names of all keys into a string array.
 For loop1 = 0 To arr1.GetUpperBound(0)
    Response.Write("Key: " & arr1(loop1) & "<br>")
    arr2 = coll.GetValues(loop1)  ' Get all values under this key.
    For loop2 = 0 To arr2.GetUpperBound(0)
       Response.Write("Value " & CStr(loop2) & ": " & arr2(loop2) &
 Next loop2 Next loop1

However, there is no place that describes how to format the querystring
to actually get this to work. I always end up with 1 key and everything
else is the "value"

I want a URL like:
to geve me a name/value collection with 2 keys with 1 value
each. DUH. But I do not know what seperator to use in the
URL. I am also troubled by a statement in the description
of the NameValueCollection that says:

  "However, unlike the NameObjectCollectionBase,
   this class stores multiple string values under
   a single key."

If that is the case, was the example ever tested with more than
1 key???

Is there a .net way to do this, or do I have to parse the QueryString
the good ole fashioned way.....


Mon, 03 May 2004 06:47:39 GMT  
 NameValueCollection, Request.QueryString, WebForm usage
Use the "&" as the delimiter:



This posting is provided ?AS IS?, with no warranties, and confers no

Mon, 03 May 2004 13:56:15 GMT  
 NameValueCollection, Request.QueryString, WebForm usage
Thx, the "&" seperator worked great...


>Use the "&" as the delimiter:



>This posting is provided ?AS IS?, with no warranties, and confers no

Tue, 04 May 2004 04:10:30 GMT  
 NameValueCollection, Request.QueryString, WebForm usage
I am glad to hear that my suggestion is helpful.


This posting is provided ?AS IS?, with no warranties, and confers no

Tue, 04 May 2004 10:32:09 GMT  
 [ 4 post ] 

 Relevant Pages 

1. Need more Request.QueryString and Request.Form help

2. Can I Request.form and Request.querystring?

3. How to use VBA to send Request QueryString to an ASP page

4. Serializing Request.Querystring

5. Problems with listbox and asp and request.querystring.

6. Request.QueryString

7. Request.QueryString

8. VBScript Equivalent to Request.Querystring

9. Merge, Request.QueryString

10. cannot get the Request.QueryString

11. Request.QueryString help

12. Request.Querystring/Form


Powered by phpBB® Forum Software