Last post May 29, 2014 04:22 AM by George Qiao
May 28, 2014 11:14 AM|SeeDosRun|LINK
Here is my problem, imagine a menu website where you can select your order from a dropdown list.
What I want is that when a user selects "main course 1" that a tablerow is added to an existing table, with the name of the main course and a textbox for comments ("medium rare", "no onions" etc) and other controls. The user should be able to select multiple
meals and add comments for each meal. The first problem I have is that every time the dropdown is changed the rows in the table for existing meals get "forgotten" and the row for the current meal is displayed. I believe I can solve this problem by having
a viewstate variable, "orders" that will hold a record of the current IDs of selected meals that will rebuild the table on every postback. What I am having trouble with is retaining the value of the controls within a row e.g the users comments.
I was thinking of making a meal class that has the relevant properties and adding objects of this class to the viewstate variable but that seemed overly complex for what I need.
Is there any simple way of retaining the state of dynamically created controls?
May 29, 2014 04:22 AM|George Qiao|LINK
Thanks for your post.
As far as I know create the viewstate variable to record the ID and recreate control is the usual and simple way in this scenario. You can refer to the information in this article: