title: Datapicker to filter data with date range
body: <p>I am searching data on the database in accordance to date range. </p>
  
  <p>In the search box how can I make the data to be picked from the datapicker.</p>
  
  <p>Here is my code :</p>
  
  <pre><code> public ActionResult List(DateTime startDate, DateTime endDate)
      {
          //var cards = new List&lt;Card&gt;();
  
          //using (CardDBEntities _db = new CardDBEntities() )
          //{
          //    cards = _db.Cards.ToList();
          //}
  
          using (var db = new CardDBEntities())
          {
              var cards = (from c in db.Cards
                           join d in db.RegistrationDTs
                           on c.CardId equals d.CardId
                           where d.RegistrationDateTime &gt;= startDate &amp;&amp;
                                 d.RegistrationDateTime &lt;= endDate
                           select new Model
                           {
                               CardId = d.CardId,
                               Description = c.Description,
                               RegistrationDateTime = d.RegistrationDateTime
                           }).OrderByDescending(x =&gt; x.RegistrationDateTime)
                            .ToList();
  
              ViewData["cards"] = cards;
  
              return View(); 
  </code></pre>
  
  <p>and my view :</p>
  
  <pre><code>@using(Html.BeginForm())
  {
  &lt;fieldset&gt;
      &lt;legend&gt;Search criteria&lt;/legend&gt;
      @Html.Label("startDate", "Start Date:")
      @Html.TextBox("startDate", null, new { @class = "DateTime" })
      @Html.Label("endDate", "End Date:")
      @Html.TextBox("endDate", null, new { @class = "DateTime" })
      &lt;input type="submit" value="Apply" /&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>Thank you in advance</p>