How to create table and Input Form in a single view
Below is my input Form View.
@model ERP_APP.Models.EmpMasterMV
@{
ViewBag.Title = "CreaterEmployee";
}
<div class="col-lg-8">
<div class="card card-default mb-5">
<div class="card-header">Employee Form</div>
<div class="card-body">
@using (Html.BeginForm("CreaterEmployee", "Employee", FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.EnrollNumber, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.EnrollNumber, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.EnrollNumber, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EmpName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.EmpName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.EmpName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.JoinDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.EMp_Doj, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.EMp_Doj, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.FatherName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FatherName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FatherName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Designation_ID, "Select Designation Level", htmlAttributes: new { @class = "control-label col-md-6" })
<div class="col-md-10">
@Html.DropDownList("Designation_ID", null, "Select Designation", htmlAttributes: new { @class = "form-control", @id = "select2-1" })
@Html.ValidationMessageFor(model => model.Designation_ID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SecId, "Select Department Level", htmlAttributes: new { @class = "control-label col-md-6" })
<div class="col-md-10">
@Html.DropDownList("SecId", null, "Select Department", htmlAttributes: new { @class = "form-control", @id = "select2-2" })
@Html.ValidationMessageFor(model => model.SecId, "", new { @class = "text-danger" })
</div>
</div>
</div>
}
</div>
</div>
</div>
and table view
@model IEnumerable<ERP_APP.Models.EmpViewModel>
@{
ViewBag.Title = "AllEmployeeList";
}
<div class="card">
<div class="card-header">
<div class="text-sm">
<div class="card-title">UserTypes</div>
</div>
</div>
<div class="card-body">
@Html.ActionLink("Create New", "CreaterEmployee", null, new { @class = "btn btn-primary" })
<hr />
<table class="table table-striped my-4 w-100" id="datatable2">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.employee.EnrollNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.employee.EmpName)
</th>
<th>
@Html.DisplayNameFor(model => model.employee.FatherName)
</th>
<th>
@Html.DisplayNameFor(model => model.employee.JoinDate)
</th>
<th>
@Html.DisplayNameFor(model => model.department.Dept_Name)
</th>
<th>
@Html.DisplayNameFor(model => model.designation.Designation_Name)
</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.employee.EnrollNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.employee.EmpName)
</td>
<td>
@Html.DisplayFor(modelItem => item.employee.FatherName)
</td>
<td>
@* @Html.DisplayFor(modelItem => item.employee.JoinDate);*@
@Convert.ToDateTime(item.employee.EMp_Doj).ToString("dd/MM/yyyy")
</td>
<td>
@Html.DisplayFor(modelItem => item.department.Dept_Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.designation.Designation_Name)
</td>
<td>
@Html.ActionLink("Edit", "EditEmployee", new { enrollnumber = item.employee.EnrollNumber }, new { @class = "btn btn-warning" }) |
@Html.ActionLink("Delete", "Delete", new { }, new { @class = "btn btn-danger" })
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
I want both view in one page