title: Asp.net MVC search using model and return different model (partial view)
body: <p>I am trying to implement search functionality in MVC view.  I have view called 'ReturnResults' and partial view (_Find) in it. _Find is object that I use to find/filter results. </p>
  
  <p>Is this the correct way to implement search? I am getting error <em>The model item passed into the dictionary is of type 'MyModels.ReturnResults', but this dictionary requires a model item of type 'MyModels.Find'.</em> </p>
  
  <p>Controller Method:</p>
  
  <pre><code>public ActionResult Locate(Find find)
  {
      List&lt;ReturnResults&gt; returnV = new List&lt;ReturnResults&gt;();
      returnV = CallDB.GetList(find)
      return View(returnV);
  }
  </code></pre>
  
  <p>View (ReturnResults):</p>
  
  <pre><code>@model MyModels.ReturnResults
  
  @{
      ViewBag.Title = "List Results";
  }
  
  @Html.Partial("_Find", Model)
  </code></pre>
  
  <p>Partial View (_Find):</p>
  
  <pre><code>@model MyModels.Find
  
  @{
      ViewBag.Title = "Find";
  }
  
  @using (Html.BeginForm("Locate", "LocateCource", FormMethod.Post, new { name = "frmLocate", id = "frmLocate"}))
  {
      &lt;td&gt;
          @Html.LabelFor(m =&gt; m.Number)
          @Html.TextBoxFor(m =&gt; m.Number)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.LabelFor(m =&gt; m.Course)
          @Html.TextBoxFor(m =&gt; m.Course)
      &lt;/td&gt;   
      &lt;td&gt;
          @Html.LabelFor(m =&gt; m.Location)
          @Html.TextBoxFor(m =&gt; m.Location)
      &lt;/td&gt;
      &lt;/td&gt;   
      &lt;td&gt;
          @Html.LabelFor(m =&gt; m.Condition1)
          @Html.TextBoxFor(m =&gt; m.Condition1)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.LabelFor(m =&gt; m.Condition2)
          @Html.TextBoxFor(m =&gt; m.Condition2)
      &lt;/td&gt;   
          &lt;td&gt;
          @Html.LabelFor(m =&gt; m.Condition3)
          @Html.TextBoxFor(m =&gt; m.Condition3)
      &lt;/td&gt;   
  }
  </code></pre>
  
  <p>Partial View:</p>
  
  <pre><code>public class Find
  {
      [Display(Name = "Number ")]
      public int Number { get; set; }
  
      [Display(Name = "Course Name")]
      public string Course { get; set; }
  
      [Display(Name = "Course Name")]
      public string Location { get; set; }
  
      [Display(Name = "Condition1")]
      public string Condition1 { get; set; }  
  
      [Display(Name = "Condition2")]
      public string Condition3 { get; set; }  
  
      [Display(Name = "Condition3")]
      public string Condition3 { get; set; }      
  }
  </code></pre>
  
  <p>View: (with Partial View)</p>
  
  <pre><code>public class ReturnResults
  {
      [Display(Name = "Number ")]
      public int Number { get; set; }
  
      [Display(Name = "Course Name")]
      public string Course { get; set; }
  
      [Display(Name = "Return1")]
      public string Return1 { get; set; }
  
      [Display(Name = "Return2")]
      public string Return2 { get; set; }
  
      [Display(Name = "Return3")]
      public string Return3 { get; set; }
  
      [Display(Name = "Return4")]
      public string Return4 { get; set; }
  
      [Display(Name = "Return5")]
      public string Return5 { get; set; }
  
      [Display(Name = "Return6")]
      public string Return6 { get; set; } 
  }
  </code></pre>