title: how to put an array elemnts into a selectable list( like dropdown) in asp.net with C# language
body: <p>I have an array which contains some elements ( it has created dynamically )
  I want to put this array elements into a selectable list/drop down menu so user can select options that i want.
  I tried using selec/option method, but i couldnt set the array elements into the option dynamically.
   usingasp.net C#</p>
  
  <p>this is my array:</p>
  
  <pre><code>string txt;
  txt = Resulttst.Text;
  if (txt != "") 
  {
      string[] delimiter = { Environment.NewLine };
      string[] ar = txt.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
  }
  </code></pre>
  
  <p>by the way i can show my array elemnts one by one but i want to put them into a selectable list</p>
  
  <p>here is the code which im using in a test mode in my view page
  tell me which part should i change to show the item1, item2, and so on in the drop down list</p>
  
  <pre><code>&lt;%   string[] arr = { "item1", "item2", "item3" };
  
   var listItems = arr.Select((r, Index) =&gt; new ListItem { Text = r, Value = Index.ToString() });
  
   DropDownList ddl = new DropDownList();
   ddl.Items.AddRange(listItems.ToArray()); %&gt;
  
  
   &lt;form runat="server" &gt;
       &lt;asp:DropDownList ID="ddl"  AutoPostBack="True" runat="server"  &gt;
    &lt;/asp:DropDownList&gt; &lt;/form&gt;
  </code></pre>