I have a form that will have this format:
- I am first row (textbox) [Submit Button]
- I am second row (radiobutton) [Submit Button]
- I am third row (checkbox) [Submit Button]
- I am fourth row (dropdown) [Submit Button]
- I am fifth row (textbox) [Submit Button]
- I am sixth row (textbox) [Submit Button]
- I am seventh row (radiobutton) [Submit Button]
The text (ex: I am fourth row) and the value of the control will be loaded from a database. I would like the Submit button to only send the value of its control (ex: row 4, dropdown value == N/A) to the server. Not all the controls’ values.
Now will I have to wrap each row with a Html.BeginForm or can I wrap all rows with one Html.BeginForm? What would be the best (or even better) way to handle such a thing.
Note: I’ve searched around SO and haven’t seen a problem like this discussed.
Sounds like you need to create a loop to build your table.. and conditionally create the rows based on whatever it is that you are keying on to decide to put a specific element type( text, radio, checkbox, etc..) and each row would be have to be wrapped in form tags. Since you would need to evaluate for the correct element, you can use that to also build your BeginForm to tell it where to post to an action, possibly a different action per element type so that the action receives only the data you want it to receive