14
<form action="test.aspx" method="post">
<input type"text" name="test[0].myitem" value="computer" />
<input type"text" name="test[0].quantity" value="1" />
<input type"text" name="test[0].price" value="US$10.5" />
<input type"text" name="test[1].myitem" value="printer" />
<input type"text" name="test[1].quantity" value="1" />
<input type"text" name="test[1].price" value="US$15.5" />
</form>

this it html source, How can I get and use this post data in asp.net c#

Request.Form["test"] and
Request.Form.getValues("test") didn't work.
Request.Form["test[0].myitem"] not work also

Aristos
  • 66,005
  • 16
  • 114
  • 150
user3444535
  • 233
  • 1
  • 2
  • 12

2 Answers2

18

Try this

string[] keys = Request.Form.AllKeys;
var value = "";
for (int i= 0; i < keys.Length; i++) 
{
   // here you get the name eg test[0].quantity
   // keys[i];
   // to get the value you use
   value = Request.Form[keys[i]];
}
Aristos
  • 66,005
  • 16
  • 114
  • 150
3

To get the data you use the name of the element as:

 Request.Form["test[0].myitem"]
 Request.Form["test[0].quantity"]

to see all the posted data you use the Request.Form.ToString()

Now, you say that this is not work for you - you have wrong, or some other security of the asp.net did not accept your post back as valid and you get an error.

I just try it on a simple page and works to me.

Aristos
  • 66,005
  • 16
  • 114
  • 150