title: Show/hide column in gridview based on Role
body: <p>I have a GridView I populate, and want to show/hide the edit link based on whether the person logged in is either an Admin or User. I am not receiving any errors but cannot figure out why its not working. </p>
  
  <p><strong>aspx</strong></p>
  
  <pre><code>    &lt;asp:GridView ID="RepView" runat="server" HeaderStyle-BackColor="#bfbfbf" HeaderStyle-ForeColor="White" HeaderStyle-Font-Underline="true" CellPadding="2" GridLines="None" AutoGenerateColumns="false" Width="990px"&gt;
      &lt;AlternatingRowStyle BackColor="#DCDCDC" /&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="Id" HeaderText="Id" /&gt;
          &lt;asp:BoundField DataField="FirstName" HeaderText="First Name" /&gt;
          &lt;asp:BoundField DataField="LastName" HeaderText="Last Name" /&gt;
          &lt;asp:BoundField DataField="EmployeeId" HeaderText="Employee Id" /&gt;
          &lt;asp:BoundField DataField="Shift" HeaderText="Shift" /&gt;
          &lt;asp:BoundField DataField="Supervisor" HeaderText="Supervisor" /&gt;
          &lt;asp:BoundField DataField="Center" HeaderText="Center" /&gt;
          &lt;asp:BoundField DataField="DateSubmitted" HeaderText="Date Entered" /&gt;
  
          &lt;asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Details"&gt;
                &lt;ItemTemplate&gt;                       
                        &lt;a href="/Admin/Details.aspx?AssignmentID=&lt;%# Eval("Id") %&gt;"&gt;Edit&lt;/a&gt;                     
                &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p><strong>code behind</strong></p>
  
  <pre><code>    Private Sub BindGrid()
      Dim DefaultConnection As String = ConfigurationManager.ConnectionStrings("DefaultConnection").ConnectionString
      Using con As New SqlConnection(DefaultConnection)
         'This is not working...
          If My.User.IsInRole("User") Then
              RepView.Columns(9).Visible = False
          ElseIf My.User.IsInRole("Admin") Then
              RepView.Columns(9).Visible = True
          End If
          ' End of questionable part....
  
          Using cmd As New SqlCommand()
              cmd.CommandText = ("SELECT * from Reps")
              cmd.Connection = con
              con.Open()
              RepView.DataSource = cmd.ExecuteReader()
              RepView.DataBind()
              con.Close()
          End Using
      End Using
  End Sub
  </code></pre>