2

I am passing value from Html.ActionLink to the controller. But the problem is in controller, value is not being fetched. I don't know what is the problem.

Here is my code :

View :

    @Html.ActionLink("Copy", "Copy", "Item", new { id = item.Item_code}, null)

Contoller :

       public ActionResult Copy(int id)
       {
                 // Logic here
                 return View();
       }
user2771704
  • 5,994
  • 6
  • 37
  • 38
Monica
  • 141
  • 4
  • 16
  • This is really strange! Look at [this](https://dotnetfiddle.net/A9VEmd) fiddle it worked for me correctly. It might give you some tip to the resolution. – Jenish Rabadiya Nov 24 '15 at 08:10

1 Answers1

1

You HTMLhelper looks OK, so that's strange. Please check a route for this link. Also type in the expected URL in browser address bar and see if you can get to controller. Also check URL when your mouse over the link. Does it show correct link?

You could try to use Url.Action instead of Html.ActionLink helper like below:

<a href="@Url.Action("Copy", "Item", new { id = item.Item_code})"> Copy</a>

Update

Since you have ID like 001020002, try to change int type to string to see if it works that way:

   public ActionResult Copy(string id)
   {
             // Logic here
             return View();
   }

in View:

@Html.ActionLink("Copy", "Copy", "Item", new { id = item.Item_code.ToString()}, null)
user2771704
  • 5,994
  • 6
  • 37
  • 38