Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:08:13+00:00 2026-05-26T13:08:13+00:00

I am trying to populate a WebGrid cell with an image that will open

  • 0

I am trying to populate a WebGrid cell with an image that will open up a “Details” popup based on which row is selected. Currently, I have this for the details column:

grid.Column(header: "Details", format: (item) => @Ajax.ActionLink("pop", "GetDetails", new { id = item.FormId }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "formdetails", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup" })
                                          , style: "colImages"),

This opens up the popup fine, but there is the text “pop” in the column instead of an image.

I have seen a number of sites talking about creating a separate “ImageActionLink” class to assist in creating ActionLink objects with images. That code looks like this:

public static class ImageActionLinkHelper
{
    public static IHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions)
    {
        var builder = new TagBuilder("img");
        builder.MergeAttribute("src", imageUrl);
        builder.MergeAttribute("alt", altText);
        var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions).ToHtmlString();
        return new MvcHtmlString(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)));
    }
} 

However, I can’t seem to get that code to work WITHIN a WebGrid. This is mostly due to the fact that I need the “(item) =>” part to get the ID of the row so that the correct details window will pop up.

How can I get the “Details” column to contain a small icon that will bring up the correct popup when clicked? Thanks in advance.

Edit: Here’s a couple ways I tried to use ImageActionLink

grid.Column(... format: (item) => @Ajax.ImageActionLink( ... ) ),

Error: Argument 3: cannot convert from ‘lambda expression’ to ‘System.Func’

grid.Column(... format: (item) => @(new HtmlString(@Ajax.ImageActionLink( ... ) ),

Error: Keyword, identifier, or string expected after verbatim specifier: @

grid.Column(... format: (item) => @HtmlString(@Ajax.ImageActionLink( ... ) ),

Error: ‘System.Web.HtmlString’ is a ‘type’ but is used like a ‘variable’

grid.Column(... format: @HtmlString((item) => @Ajax.ImageActionLink( ... ) ),

Error: ‘System.Web.HtmlString’ is a ‘type’ but is used like a ‘variable’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:08:14+00:00Added an answer on May 26, 2026 at 1:08 pm

    I’ve created a small repro and with the following syntax it’s working for me. One important thing: you need to include a using for your namespace of the ImageActionLinkHelper class at the top of your view.

    @using namespaceofImageActionLinkHelper
    ...
    
    grid.Column(header: "Details",
                        format: (item) => 
                            @Ajax.ImageActionLink(
                                @Url.Content("~/Content/images/image.jpg"),
                                "alt of the image",
                                "GetDetails",
                                new { id = item.FormId },
                                new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "formdetails", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup" })                    
                        , style: "colImages")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to populate a cursor in the procedure. like that :
I am trying to populate a tree view based on a list of staff
Trying to populate a uitable from xml, xml is already parsed. for (Row* fighter
I am trying to populate a combobox, which is part of an itemscontrol, with
I am trying to populate data in my fields depending on the value selected
I am currently trying to populate a development database on a project with a
I am trying to populate my WebGrid from LINQ to SQL. It has the
I am trying to populate a text box based on the values from a
I'm trying to populate a mx:tree component with values that I'm getting from BlazeDS.
I'm trying to populate a 'Policy' select dropdown with options based on the 'Company'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.