title: Comparing two datasources in C#
body: <p>I have a gridview, bound to a datasource whose database table contains a foreign key that is associated with the database table that is used as the datasource for a dropdownlist.</p>
  
  <p>What I want to do is if a certain <code>foreignKeyId</code> exists in <code>gridview.datasource</code>, to remove it from <code>dropdownlist.datasource</code>.</p>
  
  <p>To give a clearer idea of what/why I want what I want, the user is able to add entries to the gridview (and therefore the datasource), but I don't want the user to be able to make more than one entry for a specific type. Is there a way that a linq query could do this? </p>
  
  <p>pseudocode (note that I know <em>RemoveObjects()</em> is an invalid method)</p>
  
  <pre><code>var query = DataContext.Items.Where(item =&gt; item.TypeId == selectedTypeId);
  dropDownList.DataSource.RemoveObjects(query);
  </code></pre>
  
  <p>Here is how I bind the dropdownlist, so maybe I could do something here to <strong>not</strong> get the items with already existing TypeId's?</p>
  
  <pre><code>dropDownList.DataSource = DataContext.Items.Select(items =&gt; new
                  {
                      items.Name,
                      items.TypeId,
                  }).ToList();
  </code></pre>
  
  <p>Any suggestions or answers would be great!</p>