You could add a parameter of name to the action. If I understand what you're doing in your code correctly....
[HttpGet]
public ActionResult UpdateLead(String name = "")
{
if (!String.IsNullOrEmpty(name))
{
LoginUser user = name as LoginUser;
BusinessLead bl = new BusinessLead();
bl.Name = "some stuff";
return View(bl1);
}
if (user != null)
{
LoginUser user = Session["User"] as LoginUser;
BusinessLead bl = new BusinessLead();
bl.Name = "some stuff";
return View(bl1);
}
return RedirectToAction("Login", "Main");
}
To do this by Id:
[HttpGet]
public ActionResult UpdateLead(Int32 UserId = -1)
{
LoginUser user = Session["User"] as LoginUser;
if (UserId > -1)
{
BusinessLead bl = new BusinessLead();
bl.Name = "some stuff";
bl = GetUserInfoById(UserId); // Some method you need to make to populate your BusinessLead class based on the id field
return View(bl1);
}
if (user != null)
{
BusinessLead bl = new BusinessLead();
bl.Name = "some stuff";
return View(bl1);
}
return RedirectToAction("Login", "Main");
}
You could then use Html.ActionLink in your gridview
@Html.ActionLink(UserName, "UpdateLead" "ControllerName", new {name=UserName}, null)
Regarding your comment: Html.ActionLink generates the link for you. If you wanted to incorporate this manually, you could try something like this:
column.For(x => x.Name).Template("<a href='UpdateLead?name=${Name]'style='color:blue;'>${Name}</a>").HeaderText("Name").Width("10%");
Edit I just noticed that you mentioned (user ID 3). You can do the same thing by passing an integer. You can either have it nullable and check the value, or default it to 0 or some other number that it could never be to check against.