You don't need to create a separate views for this. I have create a sample application whatever you expect. Please follow the steps
Step1 : Create a model under the Model folder like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcApplication1.Models
{
public class MyDataViewModel
{
public string Selection { get; set; }
public List<Manager> ManagersData{get;set;}
public List<EmployeeOne> EmployeeOneData { get; set; }
public List<EmployeeTwo> EmployeeTwoData { get; set; }
}
public class Manager
{
public int Id { get; set; }
public string Name { get; set; }
}
public class EmployeeOne
{
public int Id { get; set; }
public string Name { get; set; }
}
public class EmployeeTwo
{
public int Id { get; set; }
public string Name { get; set; }
}
}
Step2: Create three Partial Views under shared folder for manager,Employee1,Employee2,etc like below
EmployeeOne Partial View
@model IEnumerable<mvcapplication1.models.employeeone>
@{
ViewBag.Title = "_employeeOne";
}
<h2>_employeeOne</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}
</table></mvcapplication1.models.employeeone>
Manager Partial View
@model IEnumerable<mvcapplication1.models.manager>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}
</table></mvcapplication1.models.manager>
Create other partial views like which return the IEnumerable collection or whatever your collection format
Step3: Create Controller(SelectViewController) and ActionResult(Index) like below
public class SelectViewController : Controller
{
public ActionResult Index()
{
var model = new MyDataViewModel();
string yourLoginStatus = "EmployeeOne";
if (yourLoginStatus == "Manager")
{
model.ManagersData = ManagerData();
model.Selection = "Manager";
}
else if (yourLoginStatus == "EmployeeOne")
{
model.EmployeeOneData = EmployeeOneData();
model.Selection = "EmployeeOne";
}
else if (yourLoginStatus == "EmployeeTwo")
{
model.EmployeeTwoData = EmployeeTwoData();
model.Selection = "EmployeeTwo";
}
return View(model);
}
public List<Manager> ManagerData()
{
var manager = new List<Manager>();
manager.Add(new Manager{Id=1,Name="Manager1"});
manager.Add(new Manager{Id=2,Name="Manager2"});
return manager;
}
public List<EmployeeOne> EmployeeOneData()
{
var employee = new List<EmployeeOne>();
employee.Add(new EmployeeOne { Id = 1, Name = "Emp1" });
employee.Add(new EmployeeOne { Id = 2, Name = "Emp2" });
return employee;
}
public List<EmployeeTwo> EmployeeTwoData()
{
var employee = new List<EmployeeTwo>();
employee.Add(new EmployeeTwo { Id = 1, Name = "EmpTwo1" });
employee.Add(new EmployeeTwo { Id = 2, Name = "EmpTwo2" });
return employee;
}
}
Step 4 :Finally Create a View by right clicking the Index action
@model MvcApplication1.Models.MyDataViewModel
@{
ViewBag.Title = "Index";
}
@if (Model.Selection == "Manager")
{
Html.RenderPartial("_manager", Model.ManagersData);
}
else if (Model.Selection == "EmployeeOne")
{
Html.RenderPartial("_employeeOne", Model.EmployeeOneData);
}
else if (Model.Selection == "EmployeeTwo")
{
Html.RenderPartial("_employeeTwo", Model.EmployeeTwoData);
}