I have a Partialview which goes on two differnet views. The two different views use differnet viewmodels. On one of the view the code is:
view1:
@model StudentsViewModel
......
.....
@Html.Partial("_StudentOtherInformation")
PartialView
@model StudentsViewModel
@if (Model.StudentList != null)
{
<input type="hidden" id="firstStudent" value= "@Model.StudentList.ElementAt(k-1).StudentID" />
}
view2:
@model SearchViewModel
....
@Html.Partial("_StudentOtherInformation")
As from the above code partial view needs to access viewmodel of view1. Im getting exception saying that partialview is getting confused with viewmodel. I did some research and found oneway is to create a parentviewmodel containing two viewmodels. But the problem is the two viemodels are in different namespaces. Is there any way I can pass the respective viewmodel to partialview from each of the views?