title: filtering grid with a datetime range asp.net mvc
body: <p>I'm a beginner in asp.net MVC. I try to create an app which allow to filter a grid of data. I have an error when I want to filter the data based on a date(in my app the field is "asked_date").
  I created 2 parameters in controllers: DateTime SelectedDateStart, DateTime SelectedDateEnd. In the controllers, I use this parameters like this:</p>
  
  <pre><code>    public ActionResult Index(string SortOrder, string SelectedDesk, string SelectedProgramme, string SelectedCountry, DateTime SelectedDateStart, DateTime SelectedDateEnd)
      {
          var missions = from s in db.missions_supportmission
                         select s;
  
          //Filtres 
          if (!String.IsNullOrEmpty(SelectedDesk))
          {
              missions = db.missions_supportmission.Include(s =&gt; s.organization_desk).Where(a =&gt; a.desk_id == SelectedDesk);
          }
          if (!String.IsNullOrEmpty(SelectedProgramme))
          {
              missions = db.missions_supportmission.Include(s =&gt; s.organization_programme).Where(a =&gt; a.programme_id== SelectedProgramme);
          }
          if (!String.IsNullOrEmpty(SelectedCountry))
          {
              missions = db.missions_supportmission.Include(s =&gt; s.organization_hi_country).Where(a =&gt; a.country_id == SelectedCountry);
          }
          //Filtres dates
          missions = db.missions_supportmission.Where(a =&gt; a.asked_date &gt; SelectedDateStart).Where(a =&gt; a.asked_date &lt; SelectedDateEnd);
          ViewBag.SelectedDateStart = SelectedDateStart;
          ViewBag.SelectedDateEnd = SelectedDateEnd;
  
          return View(missions.ToList());
      }
  </code></pre>
  
  <p>In the view I have this:</p>
  
  <pre><code>    &lt;h3&gt;Date&lt;/h3&gt;
      &lt;div class="form-group"&gt;
          &lt;label class="control-label col-md-4" for="Date"&gt;De&lt;/label&gt;
          &lt;div class="col-md-8"&gt;
              &lt;input type="date" class="form-Date" id="id" value="ViewBag.DateStart" onchange="form.submit();"&gt;
          &lt;/div&gt;
          &lt;label class="control-label col-md-4" for="Date"&gt;A&lt;/label&gt;
          &lt;div class="col-md-8"&gt;
              &lt;input type="date" class="form-Date" id="id" value="ViewBag.DateEnd" onchange="form.submit();"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>In the class I have this:</p>
  
  <pre><code>    public partial class missions_supportmission 
      {public int id { get; set; }
      public System.DateTime asked_date { get; set; }
  </code></pre>
  
  <p>When I debug I have the following error: </p>
  
  <blockquote>
    <p>"System.ArgumentException: The parameters dictionary contains a null entry for parameter 'SelectedDateStart' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult Index(System.String, System.String, System.String, System.String, System.DateTime, System.DateTime)' in 'MissionsDF.Controllers.MissionsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
    Nom du paramètre : parameters"</p>
  </blockquote>
  
  <p>Thanks for your help!</p>