I have a webgrid and in that webgrid I have a hyperlink. When user clicks on the hyperlink, I want them to go to a details page.
For this, I have a controller ‘Details’ method which takes an argument. But for some reason the argument is always null.
Where am I doing wrong??
Here is the webgrid;
grid.Column(format: (item) => Html.ActionLink("Advert", "Details", new { id = item.Title }))
and here is the controller;
public ActionResult Details(string title)
{
var ad = (from p in dc.Advert
where p.Title == title
select new AdvertIndexViewModel()
{
Title = p.Title,
UserName = p.UserProfile.Name
}).First();
return View(ad);
}
in the above method, the ‘title’ is always null…!! Will be great if someone can help me to find the mistake.
make sure the name of the route param matches the action method param. In this case,
title…