title: Find out a CHECKBOX in a DATAGRID in ASP.NET
body: <p>I have a GRIDVIEW and with several CHECKBOXS.</p>
  
  <p>When i selected a CHECKBOX I need run some code.</p>
  
  <p>To detect it, I use an EVENT HANDLER for the CHECKBOX included in a GRIDVIEW.</p>
  
  <p>I cannot access the CHECKBOX with my wrong code.</p>
  
  <p>Do you have any idea what I am doing wrong? Thanks for your help. Bye</p>
  
  <h2>ASPX</h2>
  
  <pre><code>    &lt;asp:Label ID="uxMessageDisplayer" runat="server" Visible="False" EnableViewState="False"&gt;&lt;/asp:Label&gt;
  &lt;asp:GridView ID="uxUserListDisplayer" runat="server" AutoGenerateColumns="False"
      OnRowDataBound="uxUserListDisplayer_RowDataBound"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="Active"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:CheckBox ID="uxActiveCheckBoxSelector" runat="server" AutoPostBack="true" OnCheckedChanged="uxRoleCheckBoxSelector_CheckChanged" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Users"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label runat="server" ID="uxUserNameLabelDisplayer" Text='&lt;%# Container.DataItem %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="uxLinkEditButton" runat="server" CausesValidation="False" CommandName="Edit"
                      Text="Edit"&gt;&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="uxLinkDeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                      Text="Delete"&gt;&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <h2>CODE BEHIND</h2>
  
  <pre><code>    protected void uxRoleCheckBoxSelector_CheckChanged(object sender, EventArgs e)
      {
           // Reference the CheckBox that raised this event   
          //CheckBox uxActiveCheckBoxSelector = sender as CheckBox;
  
          CheckBox activeCheckBox = (CheckBox)FindControl("uxActiveCheckBoxSelector");
  
          if (activeCheckBox.Checked == true)
          {
              uxMessageDisplayer.Text = "T - Aproved User";
              uxMessageDisplayer.Enabled = false;
          }
          else
          {
              uxMessageDisplayer.Text = "F - NOT Aproved User";
              uxMessageDisplayer.Enabled = false;
          }
         }
  </code></pre>