Wednesday, 7 August 2013

asp.net MVC: Is it possible to make it so a controller can receive a dynamic number of post request key, values with a model?

asp.net MVC: Is it possible to make it so a controller can receive a
dynamic number of post request key, values with a model?

I'm trying to get an action method in a controller to receive a post
request that has a dynamic number of key,value pairs in the form that
result from differing amounts of items that have had their payment
processed. I really want to stay away from just looping through the
FormCollection and get to the point where it's all just handled by model
binding.
Example
[HttpPost]
public ViewResult Index(CashNetReception reception)
{
//Process info in the model
return View();
}
Each item has a set number of key, value pairs. Example- if there are 2
items that were purchased then the form would contain quantity1 quantity2.
Thanks for your help!

No comments:

Post a Comment