title: The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive
body: <p>To be honest, this is my first time seeing such error </p>
  
  <pre><code>The 'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive
  </code></pre>
  
  <p>This is where the error occurs. It occurs at the databind. </p>
  
  <pre><code>protected void FillDropdown(DropDownList ddl)
  {
      using (var connAdd = new SqlConnection("Data Source = localhost; Initial Catalog = MajorProject; Integrated Security= SSPI"))
      {
          connAdd.Open();
  
          var sql = "Select policeid from PoliceAccount where status ='available' and handle ='offcase' and postedto='" + ddllocation.SelectedValue + "'";
          using (var cmdAdd = new SqlDataAdapter(sql, connAdd))
          {
              DataSet ds2 = new DataSet();
              cmdAdd.Fill(ds2);
  
              ddl.Items.Clear();
              ddl.DataSource = ds2;
              //error occurs here
              ddl.DataBind();
              ddl.Items.Insert(0, new ListItem("Police ID", ""));
              ddl.SelectedIndex = 0;
          }
      }
  }
  </code></pre>
  
  <p>I'm not very sure why would they say such a thing. I used this FillDropdown in my dropdownlist.</p>
  
  <pre><code>protected void ddlpid1_SelectedIndexChanged(object sender, EventArgs e)
  {
      if (ddlpid1.SelectedIndex &gt; 0)
      {
          Session["pid1"] = ddlpid1.SelectedValue;
  
          ListItem removeItem2 = ddlpid2.Items.FindByValue(ddlpid1.SelectedValue);
          ddlpid2.Items.Remove(removeItem2);
          ListItem removeItem3 = ddlpid3.Items.FindByValue(ddlpid1.SelectedValue);
          ddlpid3.Items.Remove(removeItem3);
          ListItem removeItem4 = ddlpid4.Items.FindByValue(ddlpid1.SelectedValue);
          ddlpid4.Items.Remove(removeItem4);
          ListItem removeItem5 = ddlpid5.Items.FindByValue(ddlpid1.SelectedValue);
          ddlpid5.Items.Remove(removeItem5);
      }
      else if (ddlpid1.SelectedItem.Text.Equals("Police ID"))
      {
          FillDropdown(ddlpid1);
          FillDropdown(ddlpid2);
          FillDropdown(ddlpid3);
          FillDropdown(ddlpid4);
          FillDropdown(ddlpid5);
  
          ddlpid2.SelectedValue = (String) Session["pid2"];
          ddlpid2_SelectedIndexChanged(this, EventArgs.Empty);
  
          ddlpid3.SelectedValue = (String) Session["pid3"];
          ddlpid3_SelectedIndexChanged(this, EventArgs.Empty);
  
          ddlpid4.SelectedValue = (String) Session["pid4"];
          ddlpid4_SelectedIndexChanged(this, EventArgs.Empty);
  
          ddlpid5.SelectedValue = (String) Session["pid5"];
          ddlpid5_SelectedIndexChanged(this, EventArgs.Empty);
      }
  }
  </code></pre>
  
  <p>I look at my codes multiple time and i see a clash in the selectedindex and selected value. All of them works individually as separate functions.</p>