Get text of ASP.NET HyperLinkField in GridView
<p>I'm trying to get the text of a HyperLinkField in a GridView's OnRowDelete event (the HyperLinkField's text is the primary key of the row I wish to delete). I understand that you can't get the text using the code I've placed below; it only works for BoundFields (for HyperLinkFields, the string is ""). But, I've been unable to find a working answer for getting this text. How do I get the displayed text from a HyperLinkField? (VS2010 w/ ASP.NET 4.0 and C#)</p>

<p>Thanks for reading!</p>

<p><strong>GridView Design</strong></p>

<pre><code>        &lt;asp:GridView ID="teamGridView" runat="server" CssClass="gridView" RowStyle-CssClass="rowStyle"
        AlternatingRowStyle-CssClass="altRowStyle" HeaderStyle-CssClass="viewsHeader"
        OnRowEditing="Team_OnRowEditing" OnRowDeleting="Team_OnRowDeleting" OnRowUpdating="Team_OnRowUpdating"
        OnRowCancelingEdit="Team_OnRowCancelingEdit"&gt;
        &lt;Columns&gt;
            &lt;asp:HyperLinkField HeaderText="Team Name" DataTextField="Team Name" DataNavigateUrlFields="Team Name"
                DataNavigateUrlFormatString="Teams.aspx?Team_Name={0}" /&gt;
            &lt;asp:BoundField HeaderText="Team Captain" DataField="Team Captains" /&gt;
            &lt;asp:CommandField Visible="false" HeaderText="Commands" ShowEditButton="true" ShowDeleteButton="true" /&gt;
        &lt;/Columns&gt;
    &lt;/asp:GridView&gt;
</code></pre>

<p><strong>GridView Populating Code</strong></p>

<pre><code>    using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["***"].ConnectionString))
        {
            // Initialize GridView and data
            teamGridView.AutoGenerateColumns = false;
            if (Convert.ToInt32(Session["UserLevel"]) &gt; 0)
            {

                teamGridView.Columns[2].Visible = true;
            }
            SqlDataAdapter teamDataAdapter = new SqlDataAdapter();
            DataSet teamDataSet = new DataSet();
            if (Request["Team_Name"] == null)
            {
                // Show the list of teams if no specific team is requested
                teamDataAdapter.SelectCommand = new SqlCommand("[Team Select]", connection);
                teamDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                teamDataAdapter.Fill(teamDataSet);
                teamGridView.DataSource = teamDataSet;
                teamGridView.DataBind();
            }
}
</code></pre>

<p><strong>GridView OnRowDeleting Code</strong></p>

<pre><code>        using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["***"].ConnectionString))
    {
        SqlCommand teamDeleteCommand = new SqlCommand("[Team Delete]", connection);
        teamDeleteCommand.CommandType = CommandType.StoredProcedure;
        teamDeleteCommand.Parameters.Add("TeamName", SqlDbType.NVarChar, 50);
        teamDeleteCommand.Parameters[0].Value = teamGridView.Rows[e.RowIndex].Cells[0].Text;
        Response.Write(teamDeleteCommand.Parameters[0].Value);
        try
        {
            connection.Open();
            teamDeleteCommand.ExecuteNonQuery();
        }
        catch (SqlException ex)
        {
            throw new Exception("Team Deletion Error");
        }
    }
</code></pre>
