title: Remove selected item from a DropDownList always removes the item on top
body: <p>I have two asp.net pages and the <code>summary.aspx</code> will be called from the first asp.net page by using <code>Response.Redirect("summary.aspx")</code>. </p>
  
  <p>Ticket is a custom class with 4 attributes (<code>String name, int age, int seat, int price</code>), their getter and setters and a <code>ToString</code> method.</p>
  
  <p><code>Session["tickets"]</code> stores the objects of Ticket class</p>
  
  <p>My Problem is that I have a dropdownlist called <code>drop_remove</code> and a button called <code>btn_remove</code>. When I click the button, it should remove the selected item and remove the corresponding object from <code>List&lt;Ticket&gt; tickets</code>. However, it always remove the top item from the dropdownlist. I am new to asp.net, please help.</p>
  
  <pre><code>public partial class summary : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          List&lt;Ticket&gt; tickets = (List&lt;Ticket&gt;)Session["tickets"];
  
          if (Session["eventName"].ToString() != null)
          {
              label_event.Text = Session["eventName"].ToString();
          }
  
          if (tickets != null)
          {
              displayTickets(tickets);
          }
  
  
          if (Session["tickets"] == null)
          {
              tickets = new List&lt;Ticket&gt;();
          }
          else
          {
              tickets = (List&lt;Ticket&gt;)Session["tickets"];
              drop_remove.Items.Clear();
              foreach (Ticket a in tickets)
              {
                  drop_remove.Items.Add(a.name.ToString());
              }
          }    
      }
  
      protected void moreTicekts_Click(object sender, EventArgs e)
      {
          Response.Redirect("default.aspx");
      }
  
  
      private void displayTickets(List&lt;Ticket&gt; tickets)
      {
          TextBox1.Text = ""; 
          System.Text.StringBuilder builder = new System.Text.StringBuilder();
  
          builder.Append(Environment.NewLine);
          foreach (Ticket a in tickets)
          {
              builder.Append(a.ToString() + Environment.NewLine);
          }
          TextBox1.Text += builder.ToString();
      }
  
      protected void btn_remove_Click(object sender, EventArgs e)
      {
          List&lt;Ticket&gt; tickets = (List&lt;Ticket&gt;)Session["tickets"];
  
  
          for (int i = 0; i &lt; tickets.Count; i++)
          {
              if (tickets[i].name.Equals(drop_remove.SelectedItem.ToString()))
              {
                  drop_remove.Items.Remove(drop_remove.SelectedItem);
                  tickets.RemoveAt(i);
                  break;
              }
          }
  
          Session["tickets"] = null;
          Session["tickets"] = tickets;
      }
  }
  </code></pre>