title: Hiding Linkbutton controls in a Formview using page index events
body: <p>I want to be able to hide some item controls on a <code>Formview</code>.  I have defined a method so that when a certain requirement is met, the <code>Add</code>, <code>Update</code> and <code>Delete</code> 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.  </p>
  
  <p>However, when the paging controls are used, and when another item is displayed in the Formview, the linkbuttons are made visible again.</p>
  
  <p>I have tried using both <code>FormView1_PageIndexChanging</code> and <code>_PageIndexChanged</code> events to re-hide the linkbuttons, in the following manner:</p>
  
  <pre><code>    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;
          }
      }
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Does anyone know why this is not working as anticipated?</p>
  
  <p>Thanks in advance,
  Gary.</p>