title: how can i limit the options in a dropdownlist to only valid options?
body: <p>allow me to further explain, i have a lot of people in my db. and they have a one to many option to have an action plan, my page displays all of the people that have action plans. i also have dropdownlist to filter threw all of the people that have action plans... this works fine. the dropdownlists work fine, the part i cannot get is that there is a dropdownlist filter with the persons name(to find all of the action plans for that one person), but the dropdownlist shows ALL the names in the db and not just the ones that have action plans, is there any way to limit the dropdownlist to only show people that HAVE action plans?</p>
  
  <p>sorry if there is already a post on this... i have been looking and looking but cannot find the solution</p>
  
  <p>thanks</p>
  
  <p>p.s. this might help.... and yes i am using MVC
  this is in my view</p>
  
  <pre><code>&lt;td&gt;&lt;%=Html.DropDownList("FORMER_BORROWER", "All")%&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%=Html.DropDownList("CURRENT_OWNERSHIP_ENTITY", "All")%&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%=Html.DropDownList("RESPONSIBLE_PARTY", "All")%&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%=Html.DropDownList("COMPLETED", "All")%&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%=Html.DropDownList("TARGET_DATE", "All")%&gt;&lt;/td&gt;
  </code></pre>
  
  <p>this is in my controller</p>
  
  <pre><code>var predicate = PredicateBuilder.False&lt;ACTION_PLAN&gt;();
      predicate = predicate.Or(p =&gt; p.COMPLETED != null);
  
      // former borrower
      if ((Request.Form["FORMER_BORROWER"] != null) &amp;&amp; Request.Form["FORMER_BORROWER"] != "")
      {
          FormerBorrower = Request.Form["FORMER_BORROWER"];
          ViewData["FORMER_BORROWER"] = new SelectList((from n in _db.Loans where (n.FORMER_BORROWER_NAME != null) select new { n.FORMER_BORROWER_NAME, FORMER_BORROWER_NAMEID = n.FORMER_BORROWER_NAME }).Distinct().ToList(), "FORMER_BORROWER_NAMEID", "FORMER_BORROWER_NAME", FormerBorrower);
          predicate = predicate.And(p =&gt; p.Loan.FORMER_BORROWER_NAME == FormerBorrower);
      }
      else
      {
          FormerBorrower = "";
          ViewData["FORMER_BORROWER"] = new SelectList((from n in _db.Loans where (n.FORMER_BORROWER_NAME != null) select new { n.FORMER_BORROWER_NAME, FORMER_BORROWER_NAMEID = n.FORMER_BORROWER_NAME }).Distinct().ToList(), "FORMER_BORROWER_NAMEID", "FORMER_BORROWER_NAME");
      }
  
      // current ownership entity
      if ((Request.Form["CURRENT_OWNERSHIP_ENTITY"] != null) &amp;&amp; Request.Form["CURRENT_OWNERSHIP_ENTITY"] != "")
      {
          CurrentOwnershipEntity = Request.Form["CURRENT_OWNERSHIP_ENTITY"];
          ViewData["CURRENT_OWNERSHIP_ENTITY"] = new SelectList((from n in _db.DOM_CURRENT_OWNERSHIP_ENTITies select n).ToList(), "CURRENT_OWNERSHIP_ENTITY", "CURRENT_OWNERSHIP_ENTITY", CurrentOwnershipEntity);
          predicate = predicate.And(p =&gt; p.Loan.DOM_CURRENT_OWNERSHIP_ENTITY.CURRENT_OWNERSHIP_ENTITY == CurrentOwnershipEntity);
      }
      else
      {
          CurrentOwnershipEntity = null;
          ViewData["CURRENT_OWNERSHIP_ENTITY"] = new SelectList((from n in _db.DOM_CURRENT_OWNERSHIP_ENTITies select n).ToList(), "CURRENT_OWNERSHIP_ENTITY", "CURRENT_OWNERSHIP_ENTITY");
      }
  
      // responsible party
      if ((Request.Form["RESPONSIBLE_PARTY"] != null) &amp;&amp; Request.Form["RESPONSIBLE_PARTY"] != "")
      {
          ResponsibleParty = Request.Form["RESPONSIBLE_PARTY"];
          ViewData["RESPONSIBLE_PARTY"] = new SelectList((from n in _db.ACTION_PLANs select n).ToList(), "RESPONSIBLE_PARTY", "RESPONSIBLE_PARTY", ResponsibleParty);
          predicate = predicate.And(p =&gt; p.RESPONSIBLE_PARTY == ResponsibleParty);
      }
      else
      {
          ResponsibleParty = null;
          ViewData["RESPONSIBLE_PARTY"] = new SelectList((from n in _db.ACTION_PLANs select n).ToList(), "RESPONSIBLE_PARTY", "RESPONSIBLE_PARTY");
      }
  
      // completed
      if ((Request.Form["COMPLETED"] != null) &amp;&amp; Request.Form["COMPLETED"] != "")
      {
          Completed = System.Convert.ToBoolean(Request.Form["COMPLETED"]);
          ViewData["COMPLETED"] = new SelectList((from n in _db.ACTION_PLANs where (n.COMPLETED != null) select new { n.COMPLETED}).Distinct().ToList(), "COMPLETED", "COMPLETED", Completed);
          predicate = predicate.And(p =&gt; p.COMPLETED == Completed);
      }
      else
      {
          Completed = System.Convert.ToBoolean(null);
          ViewData["COMPLETED"] = new SelectList((from n in _db.ACTION_PLANs where (n.COMPLETED != null) select new { n.COMPLETED }).Distinct().ToList(), "COMPLETED", "COMPLETED");
      }
  
      // target date
      if ((Request.Form["TARGET_DATE"] != null) &amp;&amp; Request.Form["TARGET_DATE"] != "")
      {
          TargetDate = System.Convert.ToDateTime(Request.Form["TARGET_DATE"]).ToString("MM/dd/yyyy");
          ViewData["TARGET_DATE"] = new SelectList((from n in _db.ACTION_PLANs select n).ToList(), "TARGET_DATE", "TARGET_DATE", TargetDate);
          predicate = predicate.And(p =&gt; p.TARGET_DATE == Convert.ToDateTime(TargetDate));
      }
      else
      {
          TargetDate = "";
          ViewData["TARGET_DATE"] = new SelectList((from n in _db.ACTION_PLANs select n).ToList(), "TARGET_DATE", "TARGET_DATE");
      }
  </code></pre>