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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:41:19+00:00 2026-06-04T15:41:19+00:00

I want to be able to hide some item controls on a Formview .

  • 0

I want to be able to hide some item controls on a Formview. I have defined a method so that when a certain requirement is met, the Add, Update and Delete linkbuttons that I have set won’t be displayed in my Formview. The code that I use to achieve this is the same as that shown below. This works correctly on initial display.

However, when the paging controls are used, and when another item is displayed in the Formview, the linkbuttons are made visible again.

I have tried using both FormView1_PageIndexChanging and _PageIndexChanged events to re-hide the linkbuttons, in the following manner:

    protected void FormView1_PageIndexChanged(object sender, EventArgs e)
    {
        // Check to see if PDP requirement has been removed
        if (txtStatusMessages.Text == "PDP Required has been set to False for this User so PDP cannot be updated or signed off.")
        {
            Control lb_n = FormView1.FindControl("LinkButton_New");
            lb_n.Visible = false;
            Control lb_e = FormView1.FindControl("LinkButton_Edit");
            lb_e.Visible = false;
            Control lb_d = FormView1.FindControl("LinkButton_Delete");
            lb_d.Visible = false;
        }
    }

I realise that the idea of checking the contents of a textbox in order to hide controls is far from ideal; but at this point I just want to ensure that I can hide the item controls using this method.

When using the debugger to run through this code, the event is fired on the use of a pager button. The visible properties are correctly changed from true to false. However, the linkbuttons are still visible.

Does anyone know why this is not working as anticipated?

Thanks in advance,
Gary.

  • 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-04T15:41:20+00:00Added an answer on June 4, 2026 at 3:41 pm

    I appear to have solved the problem.

    Initially I tried using FormView1_ModeChanging, which allowed me to cancel the change of mode from ReadOnly to Edit (Upon clicking the Edit linkbutton, for example). This worked, but meant that the linkbuttons were still visible.

    When looking into this issue some more, I found that while I could set the Linkbutton visible properties to false, they were effectively being reset. This made me think that my issue was due to event ordering (Maybe the wrong term to use) and that a refresh of the Formview was overwriting my changes.

    So, I added a new HiddenField to store Edit Allowed type data, which would be set based on whether a user should be able to update a data item or not. I then used it with the PreRender event, as follows:

        protected void FormView1_PreRender(object sender, EventArgs e)
        {
            if (hfEditAllowed.Value == "false")
            {
                Control lb_n = FormView1.FindControl("LinkButton_New");
                lb_n.Visible = false;
                Control lb_e = FormView1.FindControl("LinkButton_Edit");
                lb_e.Visible = false;
                Control lb_d = FormView1.FindControl("LinkButton_Delete");
                lb_d.Visible = false;
            }
        }
    

    This may not be an ideal solution, but allows me to manage the display of my LinkButtons as required.

    Hopefully this information will be of use to someone else!
    Gary.

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

Sidebar

Related Questions

I want to be able to have methods in a module that are not
I'm new to MVC. I want to be able to hide some actionlinks for
I want to be able to open my website and use some kind of
I want to be able to do some profiling to some app using the
I want to hide animation that shows shutter opening while presenting UIImagePickerController to take
I want to be able to show/hide the rows in a table using jquery.
On click, I want to hide/show some html code(which is obtained via a GET
I have a class that reads a pop3 email server. I want to write
Thanks to some help from a user here I was able to hide my
I have a RelativeLayout that I want to contain 4 concentric circles (a radar

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.