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 control

dynamic control

Scheduled Pinned Locked Moved ASP.NET
helpquestion
2 Posts 2 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.
  • H Offline
    H Offline
    hhems
    wrote on last edited by
    #1

    hi I have created one method createdropdown()in that i had create one dynamic dropdownlist and in selectindexchange of that dropdownlist i had created another dynamic dropdownlist and again selectedindexchange of the second dropdown . but when i run this code it will call first selectedindexchange when i select the dropdownvalue but it want call second selectedindexchange. i had done autopostBack=true for both the dropdownlist. Please Help It is some urgent Task that i have to complet. in the below ddl_SelectedIndexChanged() is call but ddl2____SelectedIndexChanged is not fired.....? // Add DropDownList Control to Placeholder private void CreateDropDownBoxes() { //int counter= Convert[ViewState ("counter"),Int32]; for (int counter = 0; counter <= NumberOfControls; counter++) { DropDownList ddl = new DropDownList(); ddl.ID = "DropDownList_ID" + (counter + 1).ToString(); ddl.AutoPostBack = true; ddl.AppendDataBoundItems = true; ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); DataTable dt = new DataTable(); dt = getdata_workspace(); ddl.DataSource = dt; ddl.DataTextField = "displayedname"; ddl.DataValueField = "id"; ddl.DataBind(); phDropDownLists.Controls.Add(ddl); phDropDownLists.Controls.Add(new LiteralControl(" ")); } } public void ddl_SelectedIndexChanged(object sender, EventArgs e) { int n = this.NumberOfControls; for (int i = 0; i < n; i++) { SqlConnection conn = new SqlConnection(connStr); string boxName = "DropDownList_ID" + (i + 1).ToString(); DropDownList ddl2_ = phDropDownLists.FindControl(boxName) as DropDownList; DropDownList ddl2___ = new DropDownList(); ddl2___.ID = "DropDownList__" + (i + 1).ToString(); ddl2___.AutoPostBack = true; ddl2___.AppendDataBoundItems = true; ddl2___.EnableViewState = true; SqlCommand cmd = new SqlCommand("select * from unit where workspaceid='" + ddl2_.SelectedValue + "'", conn); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ddl2___.Items.Add(

    C 1 Reply Last reply
    0
    • H hhems

      hi I have created one method createdropdown()in that i had create one dynamic dropdownlist and in selectindexchange of that dropdownlist i had created another dynamic dropdownlist and again selectedindexchange of the second dropdown . but when i run this code it will call first selectedindexchange when i select the dropdownvalue but it want call second selectedindexchange. i had done autopostBack=true for both the dropdownlist. Please Help It is some urgent Task that i have to complet. in the below ddl_SelectedIndexChanged() is call but ddl2____SelectedIndexChanged is not fired.....? // Add DropDownList Control to Placeholder private void CreateDropDownBoxes() { //int counter= Convert[ViewState ("counter"),Int32]; for (int counter = 0; counter <= NumberOfControls; counter++) { DropDownList ddl = new DropDownList(); ddl.ID = "DropDownList_ID" + (counter + 1).ToString(); ddl.AutoPostBack = true; ddl.AppendDataBoundItems = true; ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); DataTable dt = new DataTable(); dt = getdata_workspace(); ddl.DataSource = dt; ddl.DataTextField = "displayedname"; ddl.DataValueField = "id"; ddl.DataBind(); phDropDownLists.Controls.Add(ddl); phDropDownLists.Controls.Add(new LiteralControl(" ")); } } public void ddl_SelectedIndexChanged(object sender, EventArgs e) { int n = this.NumberOfControls; for (int i = 0; i < n; i++) { SqlConnection conn = new SqlConnection(connStr); string boxName = "DropDownList_ID" + (i + 1).ToString(); DropDownList ddl2_ = phDropDownLists.FindControl(boxName) as DropDownList; DropDownList ddl2___ = new DropDownList(); ddl2___.ID = "DropDownList__" + (i + 1).ToString(); ddl2___.AutoPostBack = true; ddl2___.AppendDataBoundItems = true; ddl2___.EnableViewState = true; SqlCommand cmd = new SqlCommand("select * from unit where workspaceid='" + ddl2_.SelectedValue + "'", conn); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ddl2___.Items.Add(

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      When do you create them ? Early enough that they are in the control tree when viewstate is restored ?

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      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