Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dynamic Dropdown list Event (SelectedIndexChanged() ) is not firing

Dynamic Dropdown list Event (SelectedIndexChanged() ) is not firing

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manikkuttan
    wrote on last edited by
    #1

    I am new to ASP.Net development in using C# In my webform there is one dropdown list called "DropDownList1". When i Select one of the items in this drpdownlist1, another dropdownlist is dynamically created called "DropdownList2". An I have to create more controls depends on the selection of "DropDownList2".But when i select DropdownList2 , its not working. ie: DropDownList_SelectedIndexChanged is not firing.Moreover the "DropDownList2" is get disappeared when i select the "DropDownList2". This is the code I have written.. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList drpDownListSender = (DropDownList)sender; string strDropDownList1ID = drpDownListSender.SelectedItem.Value; switch (strDropDownList1ID) { case "TRIN": Label SourceLabel = new Label(); SourceLabel.ID = "SourceLabel"; SourceLabel.Text = "SOURCE"; SourceLabel.Style["Position"] = "Absolute"; SourceLabel.Style["Top"] = "120px"; SourceLabel.Style["Left"] = "232px"; form1.Controls.Add(SourceLabel); DropDownList2 = new DropDownList(); DropDownList2.ID = "DropDownList2"; DropDownList2.Style["Position"] = "Absolute"; DropDownList2.Style["Top"] = "120px"; DropDownList2.Style["Left"] = "445px"; DropDownList2.AutoPostBack = true; DropDownList2.EnableViewState = true; DropDownList2.Visible = true; form1.Controls.Add(DropDownList2); DropDownList2.Items.Insert(0, "SELECT"); DropDownList2.Items.Insert(1, "CENTRAL STORE"); DropDownList2.SelectedIndexChanged += new System.EventHandler(DropDownList2_SelectedIndexChanged); break; case "TROUT": // Label4.Text = "Second Category Selected"; break; } protected void DropDownList2_SelectedIndexChanged(object sender,EventArgs e) { ViewState["DropDownList2"] = DropDownList2.SelectedValue.ToString(); TextBox TextBox3 = new TextBox(); TextBox3.ID = "TextBox3"; TextBox3.Style["Position"] = "Absolute"; TextBox3.Style["Top"] = "400px"; TextBox3.Style["Left"] = "600px";

    U M 2 Replies Last reply
    0
    • M Manikkuttan

      I am new to ASP.Net development in using C# In my webform there is one dropdown list called "DropDownList1". When i Select one of the items in this drpdownlist1, another dropdownlist is dynamically created called "DropdownList2". An I have to create more controls depends on the selection of "DropDownList2".But when i select DropdownList2 , its not working. ie: DropDownList_SelectedIndexChanged is not firing.Moreover the "DropDownList2" is get disappeared when i select the "DropDownList2". This is the code I have written.. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList drpDownListSender = (DropDownList)sender; string strDropDownList1ID = drpDownListSender.SelectedItem.Value; switch (strDropDownList1ID) { case "TRIN": Label SourceLabel = new Label(); SourceLabel.ID = "SourceLabel"; SourceLabel.Text = "SOURCE"; SourceLabel.Style["Position"] = "Absolute"; SourceLabel.Style["Top"] = "120px"; SourceLabel.Style["Left"] = "232px"; form1.Controls.Add(SourceLabel); DropDownList2 = new DropDownList(); DropDownList2.ID = "DropDownList2"; DropDownList2.Style["Position"] = "Absolute"; DropDownList2.Style["Top"] = "120px"; DropDownList2.Style["Left"] = "445px"; DropDownList2.AutoPostBack = true; DropDownList2.EnableViewState = true; DropDownList2.Visible = true; form1.Controls.Add(DropDownList2); DropDownList2.Items.Insert(0, "SELECT"); DropDownList2.Items.Insert(1, "CENTRAL STORE"); DropDownList2.SelectedIndexChanged += new System.EventHandler(DropDownList2_SelectedIndexChanged); break; case "TROUT": // Label4.Text = "Second Category Selected"; break; } protected void DropDownList2_SelectedIndexChanged(object sender,EventArgs e) { ViewState["DropDownList2"] = DropDownList2.SelectedValue.ToString(); TextBox TextBox3 = new TextBox(); TextBox3.ID = "TextBox3"; TextBox3.Style["Position"] = "Absolute"; TextBox3.Style["Top"] = "400px"; TextBox3.Style["Left"] = "600px";

      U Offline
      U Offline
      UD IA
      wrote on last edited by
      #2

      please check your dropdownlist box property autopostback is true or false if false than firstly true this property than check. :-D

      I will do my best? Integrated Solutions, Bikaner (Raj.), India

      1 Reply Last reply
      0
      • M Manikkuttan

        I am new to ASP.Net development in using C# In my webform there is one dropdown list called "DropDownList1". When i Select one of the items in this drpdownlist1, another dropdownlist is dynamically created called "DropdownList2". An I have to create more controls depends on the selection of "DropDownList2".But when i select DropdownList2 , its not working. ie: DropDownList_SelectedIndexChanged is not firing.Moreover the "DropDownList2" is get disappeared when i select the "DropDownList2". This is the code I have written.. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList drpDownListSender = (DropDownList)sender; string strDropDownList1ID = drpDownListSender.SelectedItem.Value; switch (strDropDownList1ID) { case "TRIN": Label SourceLabel = new Label(); SourceLabel.ID = "SourceLabel"; SourceLabel.Text = "SOURCE"; SourceLabel.Style["Position"] = "Absolute"; SourceLabel.Style["Top"] = "120px"; SourceLabel.Style["Left"] = "232px"; form1.Controls.Add(SourceLabel); DropDownList2 = new DropDownList(); DropDownList2.ID = "DropDownList2"; DropDownList2.Style["Position"] = "Absolute"; DropDownList2.Style["Top"] = "120px"; DropDownList2.Style["Left"] = "445px"; DropDownList2.AutoPostBack = true; DropDownList2.EnableViewState = true; DropDownList2.Visible = true; form1.Controls.Add(DropDownList2); DropDownList2.Items.Insert(0, "SELECT"); DropDownList2.Items.Insert(1, "CENTRAL STORE"); DropDownList2.SelectedIndexChanged += new System.EventHandler(DropDownList2_SelectedIndexChanged); break; case "TROUT": // Label4.Text = "Second Category Selected"; break; } protected void DropDownList2_SelectedIndexChanged(object sender,EventArgs e) { ViewState["DropDownList2"] = DropDownList2.SelectedValue.ToString(); TextBox TextBox3 = new TextBox(); TextBox3.ID = "TextBox3"; TextBox3.Style["Position"] = "Absolute"; TextBox3.Style["Top"] = "400px"; TextBox3.Style["Left"] = "600px";

        M Offline
        M Offline
        milpo
        wrote on last edited by
        #3

        hi, web pages are basically stateless. So in asp.net is using view state to maintain state. may be this article will help u to solve your problem http://forums.asp.net/p/974662/1235253.aspx#1235253[^] Regards, Aneesh Kumar

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups