Request.Form collection and duplicate keys

B

Buddy Ackerman

In ASP when a form was posted with multiple fields with the same name there
was a sub index available but that doesn't appear to be the case in .NET.
For instance in ASP you could do this:

item1 = request.form("myKey")(1)
item2 = request.form("myKey")(2)

However in .NET this type of indexing gives the following error:

Expression is not an array or a method, and cannot have an argument list

How are you supposed to iterate through a collection of items with duplicate
key names?


--Buddy
 
J

Jos

Buddy Ackerman said:
In ASP when a form was posted with multiple fields with the same name there
was a sub index available but that doesn't appear to be the case in .NET.
For instance in ASP you could do this:

item1 = request.form("myKey")(1)
item2 = request.form("myKey")(2)

However in .NET this type of indexing gives the following error:

Expression is not an array or a method, and cannot have an argument list

How are you supposed to iterate through a collection of items with duplicate
key names?


item1 = Request.Form.GetValues("myKey")(0)
item2 = Request.Form.GetValues("myKey")(1)
 

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

Top