title: DropDownList showing duplicate values in asp.net using C#
body: <p>I have only Yes and No as my item lists in my drop down but if i select "No" 3 times then it shows in my drop down list 3 times so it is duplicating each selection i make from the drop down.  After the selection it calls stored procedure which updates the back-end to either Yes or No based on the selection.  I am confused here so please help.  thanks
  Here is my ASPX code for the DD</p>
  
  <pre><code>&lt;asp:DropDownList ID="My_DD" runat="server" 
                AutoPostBack="true" DataTextField="ItemCompleted" AppendDataBoundItems="true" OnSelectedIndexChanged="DD_Changed" 
                DataValueField="ItemCompleted"&gt;
                &lt;asp:ListItem Text="Yes" Value="Yes"&gt;&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="No" Value="No"&gt;&lt;/asp:ListItem&gt;
            &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>Here is the code behind:</p>
  
  <pre><code>protected void DD_Changed(object sender, EventArgs e)
      {
          DropDownList My_DD = (DropDownList)sender;
  
          this.Bind_DD();
  
      }   
  
      protected void Bind_DD()
      {
  
          string myVar;
          myVar= My_DD.SelectedValue.ToString();
          string ID;
          ID = Request.QueryString["ID"];
          DataTable dt = new DataTable();
          String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
          SqlConnection con = new SqlConnection(strConnString);
          SqlDataAdapter sda = new SqlDataAdapter();
          SqlCommand cmd = new SqlCommand("sp_DD");
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.Add("@myVAr", SqlDbType.VarChar).Value = myVar;
          cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID;
          cmd.Connection = con;
          sda.SelectCommand = cmd;
  
          sda.Fill(dt);
          My_DD.DataSource = dt;
  
          My_DD.DataBind();
  
      }
  </code></pre>
  
  <p>Page Load code here:</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
          string Post_ID = Page.RouteData.Values["Post_ID"] as string;
  
          if (!IsPostBack)
          {
              BindData();
              BindData_ActionItems();
  
              //load DV_New
              LoadDetailView_New();       
  
          }
  
      }
  </code></pre>