title: How to use LINQ with DropDownList
body: <p>I have two dropdownlist:</p>
  
  <pre><code>&lt;asp:DropDownList ID="dropdownlist1" runat="server"&gt;
      &lt;asp:ListItem&gt;Select One&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;once&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;twice&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;thrice&lt;/asp:ListItem&gt;
  &lt;/asp:DropDownList&gt;
  
  &lt;asp:DropDownList ID="dropdownlist2" runat="server"&gt;
      &lt;asp:ListItem&gt;Select One&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;1/22/2014&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;1/25/2016&lt;/asp:ListItem&gt;
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>How can I set up LINQ to do the following:</p>
  
  <ul>
  <li>If Any of the selected index is greater than 0 then use the condition otherwise select all.</li>
  </ul>
  
  <p>I did the following:</p>
  
  <pre><code>GridView1.DataSource = List1
      .Where(en =&gt; 
          en.howManyTimes == (dropdownlist1.SelectedIndex &gt; 0 ? dropdownlist1.SelectedItem.Value : ""))
      .Select(en =&gt; new { en.TheID, en.GetFile, en.GetLink });
  </code></pre>
  
  <p>I am just not sure after the <code>:</code> in the ternary operator.</p>
  
  <p>This is what I would like:</p>
  
  <blockquote>
    <p>GridView1.DataSource = List1.Where(en => en.howManyTimes == (if
    dropdownlist1 selected index is great than 0 then use that value for
    howManyTimes, otherwise select any howManyTimes) &amp;&amp;  en.whatDate ==
    (if dropdownlist2 selected index is great than 0 then use that value
    for whatDate, otherwise select any whatDate)).Select(en => new {
    en.TheID, en.GetFile, en.GetLink });</p>
  </blockquote>
  
  <p>Can I please get some assistance in completing it.</p>