title: c# get value from gridview
body: <pre><code>           &lt;asp:TemplateField HeaderText="Employee ID" HeaderStyle-BackColor="#0033cc" HeaderStyle-ForeColor="White" ItemStyle-Width="10%"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label runat="server" ID="ONE" Text='&lt;%#Eval("REG_ID") %&gt;' /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Name" HeaderStyle-BackColor="#0033cc" HeaderStyle-ForeColor="White" ItemStyle-Width="20%"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label runat="server" ID="TWO" Text='&lt;%#Eval("Name") %&gt;' /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
     &lt;asp:TemplateField HeaderText="View" HeaderStyle-BackColor="DarkBlue" HeaderStyle-ForeColor="White" ItemStyle-Width="5%"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="report" class="btn btn-warning btn-sm" Text="Report to HR" runat="server" OnClick="report_Click" /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>Above is the code of my GridView. I want get the value of A and B from the GridView when I click the button. Any ideas how to perform this?</p>
  
  <pre><code>  protected void report_Click(object sender, EventArgs e)
  {
      GridViewRow theClickedRow = ((LinkButton)sender).NamingContainer as GridViewRow;
      if (theClickedRow != null)
      {
          Label FIRST = theClickedRow.FindControl("ONE") as Label;
          Label SECOND = theClickedRow.FindControl("TWO") as Label;
          ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + FIRST + SECOND + "');", true);
  
      }
  }
  </code></pre>
  
  <p>RESULT I get always : system web ui controlsystem web ui control</p>