title: Checkbox in ASP-GridView with FindControl NEVER checked
body: <p>I have on a ASPX-WebForm in Classic ASP a GridView with Customer-Informations for CSV-Export.</p>
  
  <p>In this GridView i have in TemplateField a Checkbox for Selection by the User.
  In CodeBehind on ClickEvent I go with ForEach-Loop through the Rows of the GridView and want to check the self-generated (data comes not from database) Checkbox if checked. With FindCOntrol i unbox the Checkbox and up to there is everything allright. But every Checkbox is NOT checked although it is checked on the Webform.</p>
  
  <p>Can anyone tell me what I´m doing wrong?</p>
  
  <p>ASPX:</p>
  
  <pre><code>&lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
  
      &lt;asp:GridView ID="GridViewAdressen" runat="server" AutoGenerateColumns="false" DataKeyNames="order_id" EnablePersistedSelection="true" style="width:100%;" PagerSettings-Mode="Numeric"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField HeaderText="Auswahl"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;input type="checkbox" name="chkSelect" runat="server"/&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  
              &lt;asp:BoundField HeaderText="ID" DataField="order_id"/&gt;
              &lt;asp:BoundField HeaderText="Zeit" DataField="zeitpunkt"/&gt;
              &lt;asp:BoundField HeaderText="Preis" DataField="preis"/&gt;
              &lt;asp:BoundField HeaderText="Name" DataField="name"/&gt;
              &lt;asp:BoundField HeaderText="Nick" DataField="username"/&gt;
  
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  
      &lt;asp:Button Text="CSV erstellen" runat="server" OnClick="Unnamed_Click"/&gt;
  
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>CodeBehind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (Request.QueryString["security"] != null &amp;&amp; Request.QueryString["security"] == token.seitenSicherheit)
      {
          // Anzahl Adressen
          string menge = "10";
          if (Request.QueryString["menge"] != null)
          {
              menge = Request.QueryString["menge"];
          }
  
          DataTable table = new DataTable();
          using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString))
          {
              connection.Open();
              using (OdbcCommand command = new OdbcCommand("SELECT * FROM bestellvorgang order by zeitpunkt desc limit " + menge, connection))
              {
                  using (OdbcDataAdapter ad = new OdbcDataAdapter(command))
                  {
                      ad.Fill(table);
                  }
              }
          }
          GridViewAdressen.DataSource = table;
          GridViewAdressen.DataBind();
      }
      else
      {
          Response.Write("Keine Zugangsberechtigung");
      }
  }
  
  protected void Unnamed_Click(object sender, EventArgs e)
  {
      // string für csv erstellen
  
      // Grid View durchlaufen und checkBox prüfen
      foreach (GridViewRow row in GridViewAdressen.Rows)
      {
          HtmlGenericControl chk = (HtmlGenericControl)row.FindControl("chkSelect");
  
  
          if (chk.Checked)
          {
              // Abfrage für den order_id
              Response.Write("Order-ID: " + GridViewAdressen.DataKeys[row.RowIndex].Value);
  
          }
  
      }
  }
  </code></pre>
  
  <p>UNBOXING WITH FINDCONTROL IS NOT NULL, BUT NEVER CHECKED !!!!!!!</p>
  
  <p>Alternatively i have tried to use Html-input Checkbox but thats always NULL when use FindControl und unbox as HtmlGenericControl ....</p>