asp.net mvc - ASP MVC3 ActionLink not rendering variables -


i trying use asp mvc3 action link navigate view (same controller). view attached model uses compound key primary key. below action link it's written on view

@html.actionlink("edit agent", "agentedit", "banklistmastercontroller",                                                  new { @agentid = int.parse(item.agentid), @id = item.id}) 

however when rendered renders following

http://localhost:2574/banklistmaster/agentedit?length=24 

which throws error:

the parameters dictionary contains null entry parameter 'agentid' of non-nullable type 'system.int32' method 'system.web.mvc.viewresult agentedit(int32, int32)' in 'monet.controllers.banklistmastercontroller'. optional parameter must reference type, nullable type, or declared optional parameter. parameter name: parameters 

here controller method measure:

    public viewresult agentedit(int agentid, int id)     {         string compare = agentid.tostring();          banklistagentid agent = (from c in db.banklistagentid                                  c.id == id &&                                        c.agentid.equals(compare)                                  select c).single();          return view("agentedit", agent);     } 

@html.actionlink("edit agent", "agentedit", "banklistmastercontroller",                                                  new { agentid = int.parse(item.agentid), id = item.id}, null) 

that should trick

and rationale is: per http://msdn.microsoft.com/en-us/library/system.web.mvc.html.linkextensions.actionlink(v=vs.108).aspx

you won't find there method (htmlhelper, string, string, string, object) there's (htmlhelper, string, string, string, object, object) second last object route values , last html attributes.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -