This is a discussion on Create dropdownlist at runtime within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi , I want to create the dropdownlist dynamically based on the selected value of dropdown. <aspropDownList ID="cascadeDropDown&...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi , I want to create the dropdownlist dynamically based on the selected value of dropdown. <asp ropDownList ID="cascadeDropDown" runat="server" AppendDataBoundItems="true" AutoPostBack="true" ><asp:ListItem Value="0" Text="Test"> </asp:ListItem> <asp:ListItem Value="1" Text="seasoning"> </asp:ListItem> <asp:ListItem Value="2" Text="test"> </asp:ListItem> <asp:ListItem Value="3" Text="Food"> </asp:ListItem> </asp ropDownList><asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder> i m creating the dropdown based on the selected value of cascadedropdown int count = System.Convert.ToInt32(cascadeDropDown.SelectedVal ue); for (int i = 0; i < count; i++) { DropDownList DDL = new DropDownList(); DDL.ID = "DDL" + i.ToString(); DDL.Items.Add(new ListItem("Veg", "0")); DDL.Items.Add(new ListItem("Type", "1")); DDL.Items.Add(new ListItem("Stored", "2")); DDL.AutoPostBack = true; DDL.SelectedIndexChanged += new System.EventHandler(this.dropListEventHandler); PlaceHolder1.Controls.Add(DDL); } and it creates as DDL0,DDL1,DDL2.... void dropListEventHandler(object sender, EventArgs e) { DropDownList dropDownListRuntTime = (DropDownList)sender; string clientId = dropDownListRuntTime.ClientID; // "dropDownListRuntTime.SelectedValue" gives you the selected value int count = System.Convert.ToInt32(dropDownListRuntTime.Select edValue); for (int i = 0; i < count; i++) { DropDownList DDLparent = new DropDownList(); DDLparent.ID = "DDLparent" + i.ToString(); DDLparent.Items.Add(new ListItem("sFood", "0")); DDLparent.Items.Add(new ListItem("sWine", "1")); DDLparent.Items.Add(new ListItem("sTest", "2")); DDLparent.AutoPostBack = true; GetDropdownIndex(DDLparent); PlaceHolder1.Controls.Add(DDLparent); } If i select DDL0, based on selected value it creates as DDLparent0.......... i should get the dropdown based on the DDLParent0.... and loop should continue....When I select DDLParent0.onselectindexchangedevent is not fired
__________________ Shaalini.S ![]() Be the Best of Whatever you are... Last edited by shaalini : 12-20-2007 at 03:12 AM. |
| Sponsored Links |
| |||
| You have to add DDLparent.onselectedindex chage property and assign method to it |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java without runtime? | STARGAZER | Java Programming | 1 | 12-28-2007 11:29 PM |
| System.Runtime.InteropServices.COMException in windows vista | $enthil | C# Programming | 3 | 11-14-2007 09:51 PM |
| how to rectify java script runtime error | vel.m8 | HTML, CSS and Javascript Coding Techniques | 1 | 11-04-2007 09:42 PM |
| Microsoft JScript runtime error: 'offsetTop' is null or not an object | vel.m8 | HTML, CSS and Javascript Coding Techniques | 0 | 11-01-2007 10:52 PM |
| DropdownList in Editable Datagrid | shaalini | ASP and ASP.NET Programming | 3 | 10-26-2007 06:07 AM |