Checkboxfield value controls button visibility
<p>I have a <code>gridview</code> wich displays the contents of a database table in rows. There is a <code>CheckboxField</code> there and a <code>Select</code> button. I want to set button visibility to false when checkboxfield is checked. </p>

<p>this is my aspx page: </p>

<pre><code>&lt;asp:DetailsView ID="DetailsViewERgo" runat="server" Height="50px"
    Width="100%" AutoGenerateRows="False" CellPadding="4" 
    DataSourceID="LinqDataSourceErgo" ForeColor="#333333" GridLines="None" 
    HeaderText="Σύντομη Περιγραφή Επιλεγμένου Έργου"&gt;      
    &lt;Columns&gt;
        &lt;asp:CheckBoxField DataField="Diekperewsi" HeaderText="Answered" 
            SortExpression="Diekperewsi" Visible="True" 
            ItemStyle-HorizontalAlign="Center"&gt;
            &lt;ItemStyle HorizontalAlign="Center" /&gt;
        &lt;/asp:CheckBoxField&gt;
        &lt;asp:TemplateField HeaderText="Insert Answer" ShowHeader="False"&gt;
            &lt;ItemTemplate&gt;
                &lt;center&gt;
                    &lt;asp:Button ID="Button1"  runat="server" CausesValidation="False" 
                        CommandName="Select" Text="Επιλογή" Visible="true" &gt;
                    &lt;/asp:Button&gt;
                &lt;/center&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>I have tried this but only works with checkboxes </p>

<pre><code>protected void GridViewAitima_RowDataBound(object sender, GridViewRowEventArgs e)
{     
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        CheckBox cb = (CheckBox)e.Row.FindControl("Diekperewsi");
        Button b = (Button)e.Row.FindControl("Button1");
        if (!cb.Checked)
        {
            b.Visible = false;
        }
        else
        {
            b.Visible = true;
        }
    }
}
</code></pre>
