I have a form in which I am gathering information from the user. Based on the value of one of the dropdowns, I am showing a panel to the user. This panel contains textboxes, dropdowns etc.
Suppose the user fills in all the values, I want to show him an add more button. On clicking this button the value in the panel should be saved somewhere and the panel should go blank for adding more values. This way a user could enter values a number of times before the final submission. On final submission all these values would be saved to a table. Could somebody guide me with the methodology of how this could be achieved??
Also I want to know how this kind of thing can be achieved at the frontend?
-
2I think you should make use of collections in back end process. Where you should store or add the data to Collection's framework classes. (like Arraylist, Vector or Map in java) and at the end final submission, push the collection's data to the database. I am sorry but I do not know much about the c# .net.Aman– Aman2013-05-06 04:42:52 +00:00Commented May 6, 2013 at 4:42
-
is there any reason why you can't save one by one? what is the application type?(winform, WPF, ASP.NET ..)Damith– Damith2013-05-06 05:04:53 +00:00Commented May 6, 2013 at 5:04
-
@Damith It is a web application. The user can add values multiple times before final submission, also he can remove some values out of the ones he added. I am not sure how can i achieve this.Kartik Gaur– Kartik Gaur2013-05-06 05:13:11 +00:00Commented May 6, 2013 at 5:13
2 Answers
You can either make use of Lists for this purpose or simple arrays.
You have not mentioned your fields clearly , but suppose they are, username, address, telephonenumber.
Then you can make list or dynamic arrays for each of these fields and on final submission, you can do Bulk Transfer to the database.
Link For Lists:
http://www.dotnetperls.com/list
Link For Bulk Insert:
http://blogs.msdn.com/b/nikhilsi/archive/2008/06/11/bulk-insert-into-sql-from-c-app.aspx
Comments
One way to do it, would be to use KnockoutJS where all adding/removing and UI manipulations are done by the library. Then submit JavaScript object as JSON to the server, serialize into objects and insert/update the database.