asp.net - Processing variable number of form fields -


I am working on a form that displays information about the order. Each order has a unique ID, but they are not ordered on the form. Additionally, the number of fields may vary (one field per field on the form). In the form the input will not directly mapped to the database, but will be added to the current value in the database, and then saved. An example of the form is in the picture below - Callouts on the right show ID for each row example of form

I know how to create a form like this, but I can not know how I can easily process each of these rows. I also know that each code has to give a unique identifier, such as name = "order-23" or name = "command [23]" , but I How can I translate that name so that I can update related records in the database?


Edit: A solution that I can think of every form code entered in FormCollection And if the name of the field matches the pattern, then I will process it by removing the number from that field-name.
However, I think that should be a very easy way to go about it - in this method there will be a lot of string processing on each field, and if possible, after the additional field for each line Must have to add in.

Do not have an ID list after your postback? I believe that you should not rely on the fact that exactly what has been sent by ID, because anyone can change the form on ID, so this is a security problem. You should have a list of the IDs you want to update in the postback (you form the form with the same list). In that case, you should know what ID string you want to get the value from the form code.

If you can not actually get a list of IDs that you are going to update, then only use formulation intrusion as you suggested in your comment being done on the request process. String processing is not expensive in comparison with all other accessories.


Comments