I have query string that has parameters like that: ...&ChildAge=3&ChildAge=4 But collection return me result as "3,4" instead of 3 and 4, with this code:
Dim a As ArrayList = New ArrayList
For i = 0 To Request.QueryString("ChildAge").Count
a.Add(Request.QueryString("ChildAge")(i))
Next
What's wrong with it? How can I get separated values?
QueryString
is a NameValueCollection
, therefore duplicate key values are concatenated as comma separated list (from the Add method):
If the specified key already exists in the target NameValueCollection instance, the specified value is added to the existing comma-separated list of values in the form "value1,value2,value3".
You can use GetValues
to retrieve a string()
for a given key:
Dim childAges As String() = Request.QueryString.GetValues("ChildAge");