title: Search date from the detail asp.Net mvc 5
body: <p><a href="http://i.stack.imgur.com/YN0Cg.png" rel="nofollow">on clicking search,nothing happen</a>I am trying to filter the detail with date property in asp.net mvc 5 code first.
  but it's not working.
  i have only create a model class from which code first generate a controller and view for it.
  now i want to filter the detail on the index page with respect to date.
  here is the code i am using.</p>
  
  <p>Model Class:-</p>
  
  <pre><code> public class Meeting
   {
      public int MeetingID { get; set; }
      public String Name { get; set; }
      public String designation { get; set; }
      [Display(Name = "9:00 - 10:00")]
      public String NineToTen { get; set; }
      [Display(Name = "10:00 - 11:00")]
      public String TenToEleven { get; set; }
      [Display(Name = "11:00 - 12:00")]
      public String ElevenToTwelve { get; set; }
      [Display(Name = "12:00 - 1:00")]
      public String TwelveToOne { get; set; }
      [Display(Name = "1:00 - 2:00")]
      public String OneToTwo { get; set; }
      [Display(Name = "2:00 - 3:00")]
      public String TwoToThree { get; set; }
      [Display(Name = "3:00 - 4:00")]
      public String ThreeToFour { get; set; }
      [Required(ErrorMessage = "Please Enter the Date")]
      [DataType(DataType.Date)]
      [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = false)]
      [Display(Name = "Meeting Date")]
      public DateTime Date { get; set; }
  
  }
  </code></pre>
  
  <p>Controller:-</p>
  
  <pre><code>       using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  using MSS.Models;
  
  namespace MSS.Controllers
  {
      public class MeetingController : Controller
      {
          private OurDbContext db = new OurDbContext();
  
          // GET: /Meeting/
          public ActionResult Index(DateTime? fromDate, DateTime? toDate)
      {
          if (!fromDate.HasValue) fromDate = DateTime.Now.Date;
          if (!toDate.HasValue) toDate = fromDate.GetValueOrDefault(DateTime.Now.Date).Date.AddDays(1);
          if (toDate &lt; fromDate) toDate = fromDate.GetValueOrDefault(DateTime.Now.Date).Date.AddDays(1);
          ViewBag.fromDate = fromDate;
          ViewBag.toDate = toDate;
          var Meeting = db.meeting.Where(c =&gt; c.Date &gt;= fromDate &amp;&amp; c.Date &lt; toDate).ToList();
  
          return View(Meeting);
      }
          // GET: /Meeting/Details/5
          public ActionResult Details(int? id)
          {
              if (id == null)
              {
                  return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
              }
              Meeting meeting = db.meeting.Find(id);
              if (meeting == null)
              {
                  return HttpNotFound();
              }
              return View(meeting);
          }
  
          // GET: /Meeting/Create
          public ActionResult Create()
          {
              return View(new Meeting { Name = User.Identity.Name });
          }
  
          // POST: /Meeting/Create
          // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
          // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Create([Bind(Include="MeetingID,Name,designation,NineToTen,TenToEleven,ElevenToTwelve,TwelveToOne,OneToTwo,TwoToThree,ThreeToFour,Date")] Meeting meeting)
          {
              if (ModelState.IsValid)
              {
                  db.meeting.Add(meeting);
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
  
              return View(meeting);
          }
  
          // GET: /Meeting/Edit/5
          public ActionResult Edit(int? id)
          {
              if (id == null)
              {
                  return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
              }
              Meeting meeting = db.meeting.Find(id);
              if (meeting == null)
              {
                  return HttpNotFound();
              }
              return View(meeting);
          }
  
          // POST: /Meeting/Edit/5
          // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
          // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Edit([Bind(Include="MeetingID,Name,designation,NineToTen,TenToEleven,ElevenToTwelve,TwelveToOne,OneToTwo,TwoToThree,ThreeToFour,Date")] Meeting meeting)
          {
              if (ModelState.IsValid)
              {
                  db.Entry(meeting).State = EntityState.Modified;
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
              return View(meeting);
          }
  
          // GET: /Meeting/Delete/5
          public ActionResult Delete(int? id)
          {
              if (id == null)
              {
                  return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
              }
              Meeting meeting = db.meeting.Find(id);
              if (meeting == null)
              {
                  return HttpNotFound();
              }
              return View(meeting);
          }
  
          // POST: /Meeting/Delete/5
          [HttpPost, ActionName("Delete")]
          [ValidateAntiForgeryToken]
          public ActionResult DeleteConfirmed(int id)
          {
              Meeting meeting = db.meeting.Find(id);
              db.meeting.Remove(meeting);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          protected override void Dispose(bool disposing)
          {
              if (disposing)
              {
                  db.Dispose();
              }
              base.Dispose(disposing);
          }
      }
  }
  </code></pre>
  
  <p>View:-</p>
  
  <pre><code>  @model IEnumerable&lt;MSS.Models.Meeting&gt;
  
    @{
      ViewBag.Title = "Index";
    }
  
    &lt;h2&gt;Index&lt;/h2&gt;
  
    &lt;p&gt;
     @Html.ActionLink("Create New", "Create")
    &lt;/p&gt;
    @{
      var fromDate = (DateTime)ViewBag.fromDate;
      var toDate = (DateTime)ViewBag.toDate;
    }
  
   @using (Html.BeginForm("Index", "Meeting", FormMethod.Get))
   {
      &lt;div&gt;
          From Date: @Html.TextBox("fromDate", string.Format("{0:dd MMM yyy}", fromDate), new { @class = "datefield", type = "date" })
          To Date: @Html.TextBox("toDate", string.Format("{0:dd MMM yyy}", fromDate), new { @class = "datefield", type = "date" })
          &lt;input type="submit" value="Search" /&gt;
      &lt;/div&gt;
  }
  &lt;table class="table"&gt;
   &lt;tr&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.Name)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.designation)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.NineToTen)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.TenToEleven)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.ElevenToTwelve)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.TwelveToOne)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.OneToTwo)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.TwoToThree)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.ThreeToFour)
       &lt;/th&gt;
       &lt;th&gt;
           @Html.DisplayNameFor(model =&gt; model.Date)
       &lt;/th&gt;
       &lt;th&gt;&lt;/th&gt;
   &lt;/tr&gt;
  
   @foreach (var item in Model) {
   &lt;tr&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.Name)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.designation)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.NineToTen)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.TenToEleven)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.ElevenToTwelve)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.TwelveToOne)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.OneToTwo)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.TwoToThree)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.ThreeToFour)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.Date)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.ActionLink("Edit", "Edit", new { id=item.MeetingID }) |
          @Html.ActionLink("Details", "Details", new { id=item.MeetingID }) |
          @Html.ActionLink("Delete", "Delete", new { id=item.MeetingID })
      &lt;/td&gt;
  &lt;/tr&gt;
  }
  </code></pre>
  
  <p></p>