I have several Textboxes generated via a foreach in the view.
To make each textbox unique I appended the item’s ID to the name and id of the textbox.
Using Ajax.BeginForm to post to a controller with a submit button…
On the controller I want to do “something” with the key/values.
[HttpPost]
public ActionResult Send(FormCollection formCollection)
{
foreach (var key in formCollection.Keys)
{
var value = formCollection[key.ToString()];
...
}
...
}
In the end I wish to either send the values to an email or save to db but not sure how to “parse” and format these key value pairs. The textBoxes are PartNumber and Price but the number of parts are generated dynamically in the view.
Try to have a list of strongly type model bound in your action method so u could write something like
you can consult Phil Haack’s article for model binding to a list. There are other bunch of articles you can find on this topic. just google “model binding to list asp.net mvc”. you will find some useful resources on first page