title: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
body: <p>I have this code that present a gridview that retrieved the data from 2 datasources.
  each line present an order details and the last column present the order status.
  the order status should be updateable in a dropdownlist .</p>
  
  <pre><code>&lt;asp:GridView runat="server" AutoGenerateColumns="False" DataSourceID="OrderDataSource"
      CssClass="DataTables"&gt;
      &lt;Columns&gt;
          &lt;asp:CommandField ShowEditButton="true" /&gt;
          &lt;asp:BoundField DataField="oID" HeaderText="oId" SortExpression="oId" ReadOnly="true" /&gt;
          &lt;asp:BoundField DataField="DateOpened" HeaderText="DateOpened" SortExpression="DateOpened"
              ReadOnly="true" /&gt;
          &lt;asp:BoundField DataField="rName" HeaderText="rName" SortExpression="rName" ReadOnly="true" /&gt;
          &lt;asp:BoundField DataField="DateOfArrival" HeaderText="DateOfArrival" SortExpression="DateOfArrival"
              ReadOnly="true" /&gt;
          &lt;asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity"
              ReadOnly="true" /&gt;
          &lt;asp:BoundField DataField="sName" HeaderText="sName" SortExpression="sName" ReadOnly="true" /&gt;
          &lt;asp:TemplateField HeaderText="osName" SortExpression="osName"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="StatusDataSource"
                      DataTextField="osName" DataValueField="osID" SelectedValue='&lt;%# Bind("osName") %&gt;'&gt;
                  &lt;/asp:DropDownList&gt;
              &lt;/EditItemTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Bind("osName") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  &lt;asp:SqlDataSource ID="OrderDataSource" runat="server" ConnectionString="&lt;%$ ConnectionStrings:igroup9_prodConnectionString %&gt;"
      SelectCommand="spGetOrdersListForProject" SelectCommandType="StoredProcedure"
      UpdateCommand="Update[Orders] set [osID] =@osID where [oID]=@oID"&gt;
      &lt;SelectParameters&gt;
          &lt;asp:ControlParameter ControlID="ProjectIDHolder" DefaultValue="" Name="ProjectID"
              PropertyName="Value" Type="Int32" /&gt;
      &lt;/SelectParameters&gt;
      &lt;UpdateParameters&gt;
          &lt;asp:Parameter Name="osID" Type="Int32" /&gt;
          &lt;asp:Parameter Name="oID" Type="Int32" /&gt;
      &lt;/UpdateParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  &lt;asp:SqlDataSource ID="StatusDataSource" runat="server" ConnectionString="&lt;%$ ConnectionStrings:igroup9_prodConnectionString %&gt;"
      SelectCommand="spGetOrderStatus" SelectCommandType="StoredProcedure"&gt;&lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>The problem is that when i'm trying to edit a column in the gridview i get this error: (after i click the edit button)</p>
  
  <pre><code>Server Error in '/Maestro' Application.
  
  'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
  Parameter name: value
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
  Parameter name: value
  </code></pre>