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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:48:49+00:00 2026-06-12T21:48:49+00:00

I have a webgrid MVC3 contains 4 columns Name, Address, age & Edit. I

  • 0

I have a webgrid MVC3 contains 4 columns Name, Address, age & Edit. I want to hide Edit link for row if age is greater than 55. Help me to do it.

Is there any event like OnItemDataBound event?

Thank you

  • 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-06-12T21:48:51+00:00Added an answer on June 12, 2026 at 9:48 pm

    Is there any event like OnItemDataBound event?

    No, there is no such concept as events in ASP.NET MVC.

    You could use a custom format column.

    Model:

    public class PersonViewModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public int Age { get; set; }
    }
    

    Controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var persons = new[]
            {
                new PersonViewModel { Id = 1, Name = "u 1", Address = "a 1", Age = 54 },
                new PersonViewModel { Id = 2, Name = "u 2", Address = "a 2", Age = 55 },
                new PersonViewModel { Id = 3, Name = "u 3", Address = "a 3", Age = 56 },
            };
            return View(persons);
        }
    }
    

    View:

    @model IEnumerable<PersonViewModel>
    @{
        var grid = new WebGrid(Model);
    }
    
    @grid.GetHtml(
        columns: grid.Columns(
            grid.Column("Name"),
            grid.Column("Address"),
            grid.Column("Age"),
            grid.Column(
                header: "Edit", 
                format: 
                    @<text>
                    @if (item.Age < 56) 
                    { 
                        @Html.ActionLink("Edit", "Edit", new { id = (int)item.Id }) 
                    }
                    </text>
            )
        )
    )
    

    Obviously the fact that you have hidden the link doesn’t relieve you from the burden to perform the same check against the Age inside the Edit controller action given the person id. There’s nothing preventing a user from entering the url of this Edit action directly in his browser address bar.

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

Sidebar

Related Questions

I Have a little problem with WebGrid control for Asp.Net MVC3. What I want
Hi I have a WebGrid with two columns: 1-Name 2-Action binded to another controller
I want to have a column as row number in MVC WebGrid. How can
I have an mvc3 webgrid that contains results that I would like to filter
I have a MVC3 WebGrid in my View.I want to display a tooltip when
I have the following WebGrid in my ASP.NET MVC3 test application. It displays a
I have a view that contains a partial view containing a WebGrid that pages
I have a webgrid and for each rows I have a link that I
I have a problem with my webgrid, in one of my columns I have
I have an MVC3 webgrid where the first column is being hidden by jQuery

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.