Please Replace this mark up and try. In MVC there is not default gridview. We need to customize our own format else use some third
party plugins like jQgrid.
@model YourNameSpace.Models.TableData
@{
ViewBag.Title = "_TableData";
}
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.EmpID)
</th>
<th>
@Html.DisplayNameFor(model => model.EmpName)
</th>
<th>
@Html.DisplayNameFor(model => model.Designation)
</th>
<th>
@Html.DisplayNameFor(model => model.Salary)
</th>
<th>
@Html.DisplayNameFor(model => model.DeptNo)
</th>
<th></th>
</tr>
@foreach (var item in Model.getObj) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.EmpID)
</td>
<td>
@Html.DisplayFor(modelItem => item.EmpName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Designation)
</td>
<td>
@Html.DisplayFor(modelItem => item.Salary)
</td>
<td>
@Html.DisplayFor(modelItem => item.DeptNo)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.EmpID }) |
@Html.ActionLink("Details", "Details", new { id=item.EmpID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.EmpID })
</td>
</tr>
}
</table>
[HttpGet]
public ActionResult Edit(int EmpID )
{
}
Replace your Controller like below
public ActionResult GetData(TableData model)
{
using (personalEntities db = new personalEntities())
{
var emply = from p in db.empdetails
select new
{
EmpID = p.empid,
EmpName = p.ename,
Designation = p.designation,
Salary = p.salary,
DeptNo = p.deptno,
};
}
model=new TableData
{
getObj=emply.ToList()
};
return View(model);
}
Hope this helps