Request.Form collection and duplicate keys

  • Thread starter Thread starter Buddy Ackerman
  • Start date Start date
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
 
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)
 
Back
Top