Reputation: 391
I need to pass a view data(integer) to another controller.
This is what i tried;
@Html.ActionLink("Get Location", "Index", "Map", new { [email protected]},null)
i need to pass this information to "Map" Controller's Index action method;
public ActionResult Index(int? i)
{
var Id = from o in db.Objects where o.Id == i select o;
return View(Id);
}
but the parameter doesn't get pass...is this the way to pass the parameter??When i put a break point i found that int? i is null..why is that??
Upvotes: 2
Views: 20090
Reputation: 2063
The parameter you're passing is Id, but your parameter in your action is i.
Rename i to Id.
Html.ActionLink("Get Location", "Index", "Map", new { [email protected]},null)
public ActionResult Index(int id)
{
var Id = from o in db.Objects where o.Id == id select o;
return View(Id);
}
Upvotes: 7