Hi sanvi,
In ActionLink Id is the routeValues which specifies, an object that contains the parameters for a route.
The parameters are retrieved through reflection by examining the properties of the object.
The object is typically created by using object initializer syntax.
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Controller
public class HomeController : Controller
{
NorthwindEntities entities = new NorthwindEntities();
public ActionResult Index()
{
return View(entities.Employees.ToList());
}
public ActionResult Details(int id)
{
Employee employee = entities.Employees.Where(e => e.EmployeeID == id).FirstOrDefault();
return View(employee);
}
}
View
Index
<html>
<head>
<title>Index</title>
</head>
<body>
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Details</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td><%: item.EmployeeID %></td>
<td><%: item.FirstName%> <%: item.LastName %></td>
<td><%: Html.ActionLink("Details", "Details", "Home", new { id = item.EmployeeID }, null)%></td>
</tr>
<% } %>
</table>
</body>
</html>
Details
<html>
<head>
<title>Details</title>
</head>
<body>
<p><%: Html.ActionLink("Back to Employee List", "Index") %></p>
<table>
<tr>
<td>Name</td>
<td><%: Model.FirstName %> <%: Model.LastName %></td>
</tr>
<tr>
<td>Date Of Birth</td>
<td><%: String.Format("{0:dd/MM/yyyy}", Model.BirthDate) %></td>
</tr>
<tr>
<td>City</td>
<td><%: Model.City %></td>
</tr>
<tr>
<td>Country</td>
<td><%: Model.Country %></td>
</tr>
</table>
</body>
</html>
Screenshot
For more details refer below link.
ActionLink Method