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

  • Home
  • SEARCH
  • 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 76277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:38:54+00:00 2026-05-10T20:38:54+00:00

On an ASP.NET page, I have a GridView populated with the results of a

  • 0

On an ASP.NET page, I have a GridView populated with the results of a LINQ query. I’m setting the DataSource in code, then calling DataBind on it. In the GridView’s RowDataBound event, I’m selectively hiding links in some GridView fields based on the query results. (For instance, I hide the ‘Show Parent’ link of the row in question has no parent row.)

This works fine initially. But on postback (when I don’t call DataBind, but the GridView stays populated through ViewState), the data displays, but the RowDataBound event (obviously) doesn’t fire, and my links don’t get hidden.

What’s the best way to get the links to be hidden after a postback?

  • 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. 2026-05-10T20:38:54+00:00Added an answer on May 10, 2026 at 8:38 pm

    Here’s how I ended up solving this:

    1. I created a serializable class with readonly properties: PK of a row, and a boolean for each link indicating whether it’s enabled or not. We’ll call it LinkVisibility.
    2. I created a serializable class inheriting from KeyedCollection to hold instances of the class above.
    3. I created a ViewState-backed property holding an instance of that collection.
    4. In my Search procedure (populating the GridView), I clear the collection.
    5. In RowDataBound, which initially shows/hides the links, I add a LinkVisibility instance to the collection for each row.
    6. In Page.Load, when IsPostBack is true, I loop through the GridView rows. I look up the LinkVisibility for each one by PK in the collection (DataKeyNames is set in the GridView), and I set the links accordingly.

    I don’t know that this is the best way to do this, but it certainly does work, which is more than I can say for anything else I’ve tried.

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

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You would probably want to use Core Animation to make… May 11, 2026 at 1:02 pm
  • added an answer From a purely querying standpoint, it makes no difference whether… May 11, 2026 at 1:02 pm
  • added an answer Here goes: ^([\d]{6})\s(?:YBB)\s([\d]{2,3})\b Explanation: a) Start at start of line.… May 11, 2026 at 1:02 pm

Related Questions

I have an ASP.NET page with a gridview control on it with a CommandButton
I have a button on an ASP.Net page that will call Response.Redirect back to
I have an ASP.Net page that will be hosted on a couple different servers,
I have an ASP.NET page which has a script manager on it. <form id=form1
I have a GridView inside an UpdatePanel that is populated when a search is
Anyone know if it possible at run-time to know how many pixels high an
I'm writing my first app with ASP.NET MVP (attempting Supervisory Controller) and Unit Testing
I have a question concerning functions with jQuery. I have a function that once

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.