Datagridview can't get the text from selected row specific control button field
<p>I have the following aspx:</p>

<pre><code> &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                BorderStyle="None" Font-Names="Verdana" Font-Size="12px" 
                OnSelectedIndexChanged="GridView1_SelectedIndexChanged" ShowHeader="False"                     
                GridLines="None" EnableModelValidation="True" Width="22%" &gt;
                    &lt;RowStyle BorderStyle="None"  Height="40px" HorizontalAlign="Left"/&gt;                            
                        &lt;Columns&gt;                                           
                            &lt;asp:HyperLinkField Text="&amp;lt;img src='../Images/CMM/download.png'/&amp;gt;"&gt;&lt;/asp:HyperLinkField&gt;                                                                
                            &lt;asp:ButtonField CommandName="Select" DataTextField="codigo" DataTextFormatString="{0:d}"
                                ItemStyle-HorizontalAlign="Left" ControlStyle-Font-Underline="true"&gt;
                                &lt;ControlStyle Font-Underline="True" /&gt;
                            &lt;/asp:ButtonField&gt;
                        &lt;/Columns&gt;
                    &lt;EditRowStyle BorderStyle="None" /&gt;
                    &lt;AlternatingRowStyle BorderStyle="None" /&gt;
                 &lt;/asp:GridView&gt;                          
</code></pre>

<p>and I have the following apsx.cs file code:</p>

<pre><code>protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{                  
        CallSaveAs(GridView1.SelectedRow.Cells[1].Text);   
}
</code></pre>

<p>the GridView1.SelectedRow.Cells[1].Text is empty but i can see it on the Debug</p>

<p>i have also tried:</p>

<pre><code>ButtonField bf = (ButtonField)GridView1.SelectedRow.Cells[1].Controls[0];
</code></pre>

<p>but i get Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'</p>

<p><strong>Finally found the solution:</strong></p>

<pre><code>    protected void GridView1_SelectedIndexChanged(object sender, EventArgs)
    {        
        LinkButton lb = (LinkButton)GridView1.SelectedRow.Cells[1].Controls[0];              
        CallSaveAs(lb.Text);   
    }
</code></pre>
