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 5983901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:17:51+00:00 2026-05-22T22:17:51+00:00

I have the following WebGrid in my ASP.NET MVC3 test application. It displays a

  • 0

I have the following WebGrid in my ASP.NET MVC3 test application. It displays a list of customers:

@grid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid.Columns
         (
         grid.Column(format: (item) => Html.ActionLink("Edit", "Details", new { id = item.id })),
         grid.Column("Address.CompanyName"),
         grid.Column("Address.City")
         )
)

The interesting part here is the Edit-link I’ve added in the first column. I would like to use the customers account number instead of the plain “Edit”-test. However, it causes me a great deal of problems to do so.

I’ve tried:

grid.Column(format: (item) => Html.ActionLink(item.AccountNumber.ToString(), "Details", new { id = item.id })),

However, it seems like there is something i don’t understand about how this works because i keep getting this exception:

CS1502: The best overloaded method match for 'System.Web.Helpers.WebGrid.Column(string, string, System.Func<dynamic,object>, string, bool)' has some invalid arguments

Can anyone explain to me why this isn’t working? What is the difference between “Edit” and item.AccountNumber.ToString() (apart from the spelling)?

I should note that the link works when using the “Edit”-text, and that AccountNumber is a long.

  • 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-22T22:17:51+00:00Added an answer on May 22, 2026 at 10:17 pm

    Here is an example of how I do it with a date.

    grid.Column(columnName: "Date", format: (item) => Html.ActionLink(((string)item.Date), "Edit", new { id = item.id })),          
    

    You have to beware of using extension
    methods (Html.*) with dynamics
    (item)… it doesn’t work well in
    csharp. When you do the new {}
    projection or call ToString, it’s no
    longer dynamic. Alternatively, you
    could cast: (object)item.Id.

    From here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.Net MVC Webgrid and when the 'SuccessRate' column is less than
I have following codes in asp.net: <asp:dropdownlist id=ddlApp runat=server /> <asp:button id=btnSmt runat=server Text=Submit
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
I have an MVC3 webgrid where the first column is being hidden by jQuery
I have following asp hyperlink: <asp:HyperLink ID=a runat=server Text=return NavigateUrl=https://google.com/></asp:HyperLink > What i want
I have recently started using ASP.Net MVC 3 RC 2 and have attempted to
I have following code, after five tries (wrong words like dfasfasfb) the application stops.
I have a WebGrid in a lot of my pages that list products. And
I am using MVC3 WebGrid control to render a list of entities. Assume I
I'm developing a web application using MVC3 in VB.NET. I having difficulty setting a

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.