I'm new to MVC
.
on MSDN i've studied that there should be folder in view
with the same name of controller
. For every Action Method
in the controller
we have to create a View
in the same folder.
I'm creating a test application in which:
I have a homeController
with an Index ActionMethod
. Corresponding to it i have a View
in View/home/Index
, which simply show the listing of the employees.
I know i can add a [HTTP POST] Index ActionMethod
in the homeController
.
But i want to add the Delete
and Search
functionality on the view. So that a user can search the employees with there name and can delete an employee on the same page.
I don't know how can i move ahead for this functionality.
Still i'm using this code.
homeController
public ActionResult Index()
{
ViewBag.text = "Records Listing";
var q = from p in objEmp.tbemployees select p;
return View(q);
}
Index.cshtml
@model IEnumerable<MvcApplication6.Models.tbemployee>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h1>@ViewBag.text</h1>
<table style="font-size:15px;">
<tr>
<th>
Name
</th>
<th>
Address
</th>
<th>
Sallary
</th>
</tr>
@foreach (var item in Model)
{
<tr >
<td style="padding:7px;">
@Html.DisplayFor(mm => item.ename)
</td>
<td style="padding:7px;">
@Html.DisplayFor(mm => item.eadd)
</td>
<td style="padding:7px;">
@Html.DisplayFor(mm => item.esal)
</td>
<td style="padding:7px; color:Blue; text-decoration:underline;">
@Html.ActionLink("Edit", "Edit", new { id = item.empno })
</td>
</tr>
}
</table>
Thanks.