---
title: "ASP MVC3 ActionLink not rendering variables"  
description: "ASP MVC3 ActionLink not rendering variables"  
author: "Royce Roy"  
published: 2013-04-05  
updated: 2013-04-05  
canonical: https://www.mindstick.com/forum/713/asp-mvc3-actionlink-not-rendering-variables  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# ASP MVC3 ActionLink not rendering variables

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to use an ASP MVC3 action link to navigate to another view (same controller). The view is attached to a model that uses a compound key for its \
[primary key](https://www.mindstick.com/blog/214/primary-key). Below is the action link as it's written on the view\
@[Html.ActionLink](https://www.mindstick.com/forum/157896/what-is-the-difference-between-the-html-actionlink-and-ajax-actionlink-helpers-in-asp-dot-net-mvc)("Edit Agent", "AgentEdit", "BankListMasterController", new { @agentId = int.Parse(item.AgentId), @id = item.ID})However when this is rendered it renders as the following\
http://localhost:2574/BankListMaster/AgentEdit?Length=24Which obviously throws an error:\
The [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) [dictionary](https://www.mindstick.com/articles/1500/hashtable-and-dictionary-in-c-sharp) contains a null entry for parameter 'agentId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ViewResult AgentEdit\
(Int32, Int32)' in 'Monet.Controllers.BankListMasterController'. An [optional parameter](https://www.mindstick.com/interview/1310/how-do-i-simulate-optional-parameters-to-com-calls) must be a [reference type](https://www.mindstick.com/interview/235/what-is-difference-between-value-types-and-reference-types-in-vb-dot-net-or-c-sharp-value-types-vs-reference-types), a nullable type, or be [declared as](https://www.mindstick.com/interview/2711/what-if-the-main-method-is-declared-as-private) an \
optional parameter.Parameter name: parametersHere is the [controller method](https://www.mindstick.com/forum/157312/how-to-call-a-controller-method-after-load-view-successfully-in-mvc-4) for good measure:\
public ViewResult AgentEdit(int agentId, int id) { string compare = agentId.ToString();\
BankListAgentId agent = (from c in db.BankListAgentId where c.ID == id && c.AgentId.Equals(compare) select c).Single();\
return View("AgentEdit", agent); }

## Replies

### Reply by AVADHESH PATEL

Hi Royce!\
try action link as below\
@Html.ActionLink("Edit Agent", "AgentEdit", "BankListMasterController", new { agentId = int.Parse(item.AgentId), id = item.ID}, null)\


---

Original Source: https://www.mindstick.com/forum/713/asp-mvc3-actionlink-not-rendering-variables

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
