Take the 2-minute tour ×

I am currently working on a project. Basically, it is a web system for a tourism company. So the company wants to sell cultural tour programs to the customers. On the reservation page, the user will determine the number of the rooms he/she wants buy. It is a dropdownlist. Then if he/she selects 5 for instance, then new 5 dropdownlists will appar. By this new 5 dropdownlists, he/she will determine the type of the room that they want to stay at. These 5 new dropdownlists lets call them "x" will have click events. The problem is that when I click one of the x's item, the click event doenst work. Besides after that they disappears. I added xes to a panel. I have tried to hold the panel by using viewstate but couldnt get any solution. Can you help me?

                                <asp:Label ID="lblRoom" runat="server" Text="How many rooms?"></asp:Label><asp:DropDownList
                                    ID="DropDownList1" runat="server" CssClass="select" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
                                <asp:Panel ID="pnlDdl" runat="server" Width="300px" >

Panel newPanel = (Panel)Session["pnlDdl"];
                int a = 0;
                if (newPanel != null)
                    a = newPanel.Controls.Count;
                pnlDdl = newPanel;
                int selectedItem = Convert.ToInt32(DropDownList1.SelectedItem.Text);
                for (int i = 2; i <= selectedItem; i++)
                    DropDownList ddl = new DropDownList();
                    ddl.ID = "roomType_" + i;
                    ddl.Items.Add(new ListItem("2 Adults", "0"));
                    ddl.Items.Add(new ListItem("2 Adults 1 Extra", "1"));
                    ddl.Items.Add(new ListItem("2 Adults 1 Child", "2"));
                    ddl.Items.Add(new ListItem("1 Adult", "3"));

                    ddl.AutoPostBack = true;
                    ddl.SelectedIndexChanged += new EventHandler(RoomTypeDDL_SelectedIndexChanged);
                    Label lb = new Label();
                    lb.Text = i + ".Type";
share|improve this question
Please add some source code to illustrate what you have achieved so far. –  PirateKitten Sep 28 '11 at 10:28
@PirateKitten I added some source code –  Ktt Sep 28 '11 at 10:34
@PirateKitten after all those, the xes disappear. But when I try to click one of the xes' item, the page postsbacks and I loose all of them. I dont want to loose all of them and I need to achieve the click event to create a new table –  Ktt Sep 28 '11 at 10:36
add comment


Your Answer



Browse other questions tagged or ask your own question.