i want to render partial view to the parent view which is tightly couple with another model
1- my _EmployeeSearch Partial view
@model ...Models.EmployeeSearchModel
@using (Html.BeginForm("Details", "Employee", FormMethod.Get, new { @class = "form-group" }))
{
<text>First Name:</text> <span class="input-icon">
@Html.TextBoxFor(model => model.FName)<i class="ace-icon fa fa-search nav-search-icon"></i>
</span>
<input type="submit" value="Search" class="btn btn-xs btn-yellow active" />
}
2- Parent View
@model IEnumerable<...Models.EmpPersonalInfoModel>
<div>
@Html.Partial("_EmployeeSearch", Model.FirstOrDefault().EmployeeSearchModel)
</div>
3- EmpPersonalInfoModel.cs
public class EmpPersonalInfoModel
{
...
public string FName { get; set; }
public EmployeeSearchModel { get; set; };
}
4- EmployeeSearch.cs model
public class EmployeeSearchModel
{
public string FName { get; set; }
}
5- and mycontroller method is
public ActionResult Details(EmployeeSearchModel searchModel)
{
Service_Employee service_ = new Service_Employee();
List<EmpPersonalInfoModel> emp_model = new List<EmpPersonalInfoModel>();
if(searchModel == null)
{ emp_model = service_.GetAllEmployees(); }
if(searchModel !=null)
{ emp_model = service_.SearchEmployee(searchModel); }
return View(emp_model);
}
But i get the error while rendering partial view into Parent view on this line expecting to have EmpPersonalInfoModel instead of EmployeeSearchModel
@Html.Partial("_EmployeeSearch", Model.FirstOrDefault().EmployeeSearchModel)
Any one have idea about this error