title: Not getting control inside rowdatabound event
body: <p>I have a grid view in my project. If the project is logged in as admin it has feauters to edit and view. But when i log in as user i want to disable the edit option.
  I am trying to disable the edit option which is a link button inside template field, but i am getting error doing this.</p>
  
  <p>Below is my code i tried so far:</p>
  
  <pre><code>protected void gvDocuments_RowDataBound(object sender, GridViewRowEventArgs e)
          {
              string username = Convert.ToString(Session["Username"]);
              LinkButton btn = (LinkButton)gvDocuments.FindControl("lbtnEdit");
  
                   if (username == "user")
                   {
                      btn.Visible = false;
                   }
  
          }
  </code></pre>
  
  <p>Can someone help me where i had gone wrong???</p>
  
  <p><strong>Edited:</strong></p>
  
  <pre><code>&lt;asp:GridView ID="gvDocuments" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvDocuments_RowDataBound" OnRowCommand="gvDocuments_RowCommand" PageSize="5" Width="100%" RowStyle-BackColor="#9FCFFF" SortedAscendingHeaderStyle-VerticalAlign="Bottom" SortedAscendingHeaderStyle-HorizontalAlign="Left" BackColor="#9BCDFF" HeaderStyle-BackColor="#51A8FF"&gt;
      &lt;asp:TemplateField HeaderText="Actions"&gt;
          &lt;itemtemplate&gt;
              &lt;asp:LinkButton ID="lbtnView" runat="server" CommandName="View" Text="View" ForeColor="#0033CC"&gt;&lt;/asp:LinkButton&gt;
              &lt;asp:LinkButton ID="lbtnEdit" runat="server" CommandName="DocEdit" Text="Edit" ForeColor="#0033CC"&gt;&lt;/asp:LinkButton&gt;
              &lt;asp:LinkButton ID="lbtnRenew" runat="server" CommandName="Email" Text="Email" ForeColor="#0033CC"&gt;&lt;/asp:LinkButton&gt;
          &lt;/itemtemplate&gt;
      &lt;/asp:TemplateField&gt;
  &lt;/asp:GridView&gt;
  </code></pre>