title: Reading selected ITEMS from Dynamically Created ListBox in asp.net
body: <p>i have created ListBox's Dynamically in a panel and i want to read the selected item from the Listbox created dynamically . below is the code that i used to create the Dynamic Listbox. can anyone please help me how to get the dynamically created listbox and then read the item selected.                                                                                'protected void GotoReport_Click(object sender, ImageClickEventArgs e)
          {</p>
  
  <pre><code>        foreach (TreeNode tndim in tvCubedef.CheckedNodes)
          {
  
              lbFilter.Items.Add(tndim.Text);
  
          }
          foreach (ListItem item in lbFilter.Items)
          {
              item.Selected = true;
          }
  
          panFilter.Controls.Clear();
          connstr2 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
          conn2.ConnectionString = connstr2;
          conn2.Open();
          CubeCollection CubeList = conn2.Cubes;
          string cb = ddlCubeList.SelectedItem.Text;
  
          foreach (ListItem li in lbFilter.Items)
          {
  
              ListBox listb = new ListBox();
              ListItem Memlist = new ListItem();
              listb.SelectionMode = System.Web.UI.WebControls.ListSelectionMode.Multiple;
              listb.Height = 150;
              listb.Width = 250;
  
              string Repl1 = li.Value.Replace("[", "");
              string Repl2 = Repl1.Replace("]", "");
              string[] DimMember = Repl2.Split('.');
              foreach (Member dimem in CubeList[cb].Dimensions[DimMember[0]].Hierarchies[DimMember[1]].Levels[DimMember[2]].GetMembers())
              {
  
                  Memlist.Text = dimem.Name;
                  listb.Items.Add(Memlist);
                  panFilter.Controls.Add(listb);
  
              }
  
          }
  
  
      } '
  </code></pre>