Click here to Skip to main content
16,017,297 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a action method in the controller CountryController.cs
C#
public ActionResult LanguageEdit(int id)
       {

Also to navigate to it,
@Html.ActionLink("Edit", "LanguageEdit", "Country", new { id = item.LanguageId }


I checked the value
item.LanguageId

It is 4. But I received the exception:
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult LanguageEdit(Int32)


Why?

What I have tried:

My route's configuration is:
routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
            );
Posted
Updated 26-Jun-17 0:49am
v2

1 solution

You might want to try
C#
@Html.ActionLink("Edit", "LanguageEdit", "Country", new { id = item.LanguageId }, null)
instead
If you check List of ActionLink overloads you'll see that there is none wich assepts link text, action name, controller name and route values dictionary.But there is one which accepts those params and html attributes dictionary
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900