Request.QueryString looping....easy question...

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

I need to do the following...

FOR myitem IN Request.Querystring
'get the key
'get the value
NEXT

What do I DIM myitem as? DictionaryEntry doesn't work...or do I have to
loop through it by index and get the key then the item out of the query
string...

thanks
Doug
 
Lenn,
Tried that and I checked the type and it came back as string....basicly
just the key names that are part of my querystring....

Doug
 
Thanks Justin...but this still requires me to give an index or a name to the
collection object....

dim myitem as NameValueCollection
dim sKey as string
Dim sValue as string
for each myitem in Request.QueryString
'here item needs an index/name...
sKey = myitem.item(some index or name)
next

I thought there was a way to iterate through the querystring collection
without having a counter....using for each then
sKey = myitem.key
sValue = myitem.value
etc...

thanks
Doug
 
Doug,

No, then you can loop through the keys...

Dim Value As String

For Each Item As System.Collections.Specialized.NameValueCollection In
Request.QueryString

For Each Key As String In Item.AllKeys

Value = Item.Get(Key)

Next

Next


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Doug,

Don't know what I was thinking when I typed out that code. (The code works
fine) I should have used the variable name "Collection" instead of "Item".

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
And Geez, now that I test the code out why not just cut right to the chase
and simplify like this:

Dim Value As String

For Each Item As String In Request.QueryString.AllKeys

Value = Item.Get(Key)

Next



Sorry, it took me so long to get to the correct code for you.


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Doug,

Man, I need some rest. See what staying up till 2:00am drinking mountain dew
and coding can do to you!

The code with the two for nexts was the right way.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Doug,

I've splashed some cold water on my face and going for a record number of
posts by one person on the same topic here is the code you need:


Dim Value As String

For Each Key As String In Request.QueryString.AllKeys

Value = Request.QueryString(Key)

Next




--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Thanks Justin....I'm feeling the same...too much work not enough
sleep...thanks for the replys...

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top