title: Get Value from ASP.NET GridView cell
body: <p>How would I get the value from a GrivView cell when the edit button is clicked?
  I have tried other answer but none seem to work.
  I would like to be able to get the value of Questionnaire ID for the row when the edit button is pressed.</p>
  
  <p>Here is the gridview im working with.</p>
  
  <pre><code>&lt;asp:GridView runat="server" ID="gvShowQuestionnaires" HeaderStyle-CssClass="table_header" CssClass="view" AlternatingRowStyle-CssClass="alt" AutoGenerateColumns="False" 
              DataKeyNames='QuestionnaireID' OnRowDeleting="gvShowQuestionnaires_RowDeleting" OnRowEditing="edit" ShowFooter="true" FooterStyle-CssClass="view_table_footer"&gt; 
                  &lt;Columns&gt;
                      &lt;asp:BoundField DataField="QuestionnaireID" HeaderText="ID" HeaderStyle-Width="80px" ItemStyle-CssClass="bo"&gt;&lt;/asp:BoundField&gt;
                      &lt;asp:BoundField DataField="QuestionnaireName" HeaderText="Questionnaire Name" /&gt;           
                      &lt;asp:TemplateField HeaderText="Results" HeaderStyle-Width="150px"&gt;&lt;/asp:TemplateField&gt;
                      &lt;asp:CommandField HeaderText="Options" ShowDeleteButton="True" ShowEditButton="true"  ItemStyle-CssClass="cart_delete"&gt;
                      &lt;/asp:CommandField&gt;
                  &lt;/Columns&gt; 
              &lt;/asp:GridView&gt;
  
                  &lt;asp:label ID="ab" runat="server"&gt;&lt;/asp:label&gt;
  </code></pre>
  
  <p>The backend</p>
  
  <pre><code>protected void edit(object sender, GridViewEditEventArgs e)
          {
  
              string c = gvShowQuestionnaires.Rows[index].Cells[0].Text;
              ab.Text = c;
  
          }
  </code></pre>