title: How to use a hyperlink in a gridview to execute a function in aspx code behind
body: <p>How to use a hyperlink in a gridview to execute a function in <code>aspx</code> code behind when clicked passing a variable to that function which is some value of a cell within the row the hyperlink exits in.</p>
  
  <p>Example:
  HTML Code:</p>
  
  <pre><code>  &lt;asp:GridView ID="GridView1" runat="server"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField HeaderText="HeaderText" SortExpression="HeaderText"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="Hyperlink1" runat="server" Text="Hyperlink1"
                          OnClick="SomeFunction(GridView1.Row.Cells(0).Text)" /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>ASP Code Behind:</p>
  
  <pre><code>Sub SomeFunction(ByVal sVariable As Object)
  
         'Do some stuff
  
  End Sub
  </code></pre>