title: SelectedValue which is invalid because it does not exist in the list of items
body: <p>This is the error I get: </p>
  
  <blockquote>
    <p>ddlRankEdit' has a SelectedValue which is invalid because it does not
    exist in the list of items. Parameter name: value</p>
  </blockquote>
  
  <p>I have a form wiht several dropdownlists that are nested in a panel that is by default set to invisible. When a user selects a record from a separate list box the selected index changed event sets the panel to visible and makes a data call. That's when the error happens. See the code below, I added XXX where it stalls.</p>
  
  <pre><code>&lt;asp:DropDownList runat="server" ID="ddlRankEdit" CssClass="txtfield" DataSourceID="ODCRanks"
    DataTextField="Rank" DataValueField="ID" AppendDataBoundItems="True"&gt;
    &lt;asp:ListItem Text="--- Select a Rank ---" Value="-1" /&gt;                                            
    &lt;/asp:DropDownList&gt;
    &lt;asp:ObjectDataSource ID="ODCRanks" runat="server" 
      OldValuesParameterFormatString="original_{0}" SelectMethod="GetRanks" 
      TypeName="RanksTableAdapters.RankTableAdapter"&gt;&lt;/asp:ObjectDataSource&gt;
  
  protected void lboxManageMembers_SelectedIndexChanged(object sender, EventArgs e)
  {
      pnlReviewMemberDetails.Visible = false;
      pnlUnlockUserAccount.Visible = false;
      pnlAdmins.Visible = false;
      pnlCreateAdmins.Visible = false;
      lblNote.Visible = false;
      pnlManageMenbers.Visible = true;
  
      MembershipUser user = Membership.GetUser();
      DataSetTableAdapters.MemberInfoTableAdapter da = new DataSetTableAdapters.MemberInfoTableAdapter();
  
      Guid _memberId = Guid.Empty;
      _memberId = new Guid(lbxManageMembers.SelectedValue);
      DataSet.MemberInfoDataTable dt = da.GetMember(_memberId);
      if (dt.Rows.Count == 1)
      {
          DataSet.MemberInfoRow mr = dt[0];
  
     XXX ddlRankEdit.SelectedValue = Convert.ToString(mr.rankid);
     XXX ddlPatrolEdit.SelectedValue = Convert.ToString(mr.patrolid);
     XXX ddlPositionEdit.SelectedValue = Convert.ToString(mr.bsaposid);
  
          txtFirstNameEdit.Text = mr.firstname;
          txtLastNameEdit.Text = mr.lastname;
          txtEmailEdit.Text = user.Email;
          txtAddressEdit.Text = mr.address;
          txtPhoneEdit.Text = mr.phone;
          txtCellPhoneEdit.Text = mr.altphone;
          txtAltEmailEdit.Text = mr.altemail;
  
          txtMotherFirstNameEdit.Text = mr.parentfn;
          txtMotherLastNameEdit.Text = mr.parentln;
          txtMotherWorkPhoneEdit.Text = mr.parentworkphone;
          txtMotheHomePhoneEdit.Text = mr.parentworkphone;
          txtMotherCellkPhoneEdit.Text = mr.parentscellphone;
          txtMotherTwitterEdit.Text = mr.parenttwitter;
          txtMotherEmailEdit.Text = mr.parentemail;
          txtMotherAltEmailEdit.Text = mr.parentemailalt;
  
          txtFatherFirstNameEdit.Text = mr.parent2fn;
          txtFatherLastNameEdit.Text = mr.parent2ln;
          txtFatherWorkPhoneEdit.Text = mr.parent2workphone;
          txtFatherHomePhoneEdit.Text = mr.parent2workphone;
          txtFatherCellPhoneEdit.Text = mr.parent2cellphone;
          txtFatherTwitterEdit.Text = mr.parent2twitter;
          txtFatherEmailEdit.Text = mr.parent2email;
          txtFatherAltEmailEdit.Text = mr.parent2emailalt;
      }
  
  }
  </code></pre>