What is the syntax for creating a link that navigates from one Controllers View to another? The following is code that is supposed to allow the user to navigate from the Index.cshtml of the FollowUpItems View to the Details.cshtml of the Agent View. I need to pass the value of item.Key1 in order for the Details.cshtml page to know exactly who to display.
I’m getting the following error and I have no clue what this means (I apologize for any lack on information, I am still very new to ASP MVC):
‘The parameters dictionary contains a null entry for parameter ‘id’ of non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ViewResult Details(Int32)’ in ‘Monet.Controllers.FollowUpController’. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters ‘
<td>
@Html.ActionLink(item.Key1, "Details", "Agent", new { id = item.Key1 })
</td>
Here is the Index() method header of the page I’m trying to navigate to:
public ActionResult Index(string searchString, string sortOrder, string currentFilter, int? page)
{
Try this overload
The third parameter is the routevalues and the fourth parameter is html attrubutes. If you want your link to have some html attributes, you may remove the null with some html attrubtes there like this
Here is the complete list of all available overloads.